﻿(function() {
  var mw = window.MetawebSuite;
  mw.system.flagPackageAsCompiled("metaweb-suite-core");
  mw.system.flagPackageAsCompiled("metaweb-suite-ui");
  mw.system.flagPackageAsCompiled("metaweb-suite-freebase");
})();


/* core-package.js */
(function() {
    mw.system.onStartLoadingNativePackage(
        "core",
        [   "externals/jquery-1.2.6.min.js",
            "externals/json2.js",
            "externals/rison.js",
            
            "externals/jquery-ui-personalized-1.5.2.packed.js",
            "externals/jquery.cookie.js",
            
            "listener-queue.js",
            "jsonp-queue.js",
            "string.js",
            "misc.js",
            "terminal.js"
        ],
        [   // no CSS
        ]
    );
})();


/* core-bundle.js */


/* jquery-1.2.6.min.js */
(function(){var _jQuery=window.jQuery,_$=window.$;
var jQuery=window.jQuery=window.$=function(selector,context){return new jQuery.fn.init(selector,context);
};
var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,isSimple=/^.[^:#\[\.]*$/,undefined;
jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;
if(selector.nodeType){this[0]=selector;
this.length=1;
return this;
}if(typeof selector=="string"){var match=quickExpr.exec(selector);
if(match&&(match[1]||!context)){if(match[1]){selector=jQuery.clean([match[1]],context);
}else{var elem=document.getElementById(match[3]);
if(elem){if(elem.id!=match[3]){return jQuery().find(selector);
}return jQuery(elem);
}selector=[];
}}else{return jQuery(context).find(selector);
}}else{if(jQuery.isFunction(selector)){return jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);
}}return this.setArray(jQuery.makeArray(selector));
},jquery:"1.2.6",size:function(){return this.length;
},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];
},pushStack:function(elems){var ret=jQuery(elems);
ret.prevObject=this;
return ret;
},setArray:function(elems){this.length=0;
Array.prototype.push.apply(this,elems);
return this;
},each:function(callback,args){return jQuery.each(this,callback,args);
},index:function(elem){var ret=-1;
return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this);
},attr:function(name,value,type){var options=name;
if(name.constructor==String){if(value===undefined){return this[0]&&jQuery[type||"attr"](this[0],name);
}else{options={};
options[name]=value;
}}return this.each(function(i){for(name in options){jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));
}});
},css:function(key,value){if((key=="width"||key=="height")&&parseFloat(value)<0){value=undefined;
}return this.attr(key,value,"curCSS");
},text:function(text){if(typeof text!="object"&&text!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));
}var ret="";
jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8){ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);
}});
});
return ret;
},wrapAll:function(html){if(this[0]){jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;
while(elem.firstChild){elem=elem.firstChild;
}return elem;
}).append(this);
}return this;
},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);
});
},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);
});
},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1){this.appendChild(elem);
}});
},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1){this.insertBefore(elem,this.firstChild);
}});
},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);
});
},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);
});
},end:function(){return this.prevObject||jQuery([]);
},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);
});
return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);
},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div");
container.appendChild(clone);
return jQuery.clean([container.innerHTML])[0];
}else{return this.cloneNode(true);
}});
var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined){this[expando]=null;
}});
if(events===true){this.find("*").andSelf().each(function(i){if(this.nodeType==3){return ;
}var events=jQuery.data(this,"events");
for(var type in events){for(var handler in events[type]){jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);
}}});
}return ret;
},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);
})||jQuery.multiFilter(selector,this));
},not:function(selector){if(selector.constructor==String){if(isSimple.test(selector)){return this.pushStack(jQuery.multiFilter(selector,this,true));
}else{selector=jQuery.multiFilter(selector,this);
}}var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;
return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;
});
},add:function(selector){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector=="string"?jQuery(selector):jQuery.makeArray(selector))));
},is:function(selector){return !!selector&&jQuery.multiFilter(selector,this).length>0;
},hasClass:function(selector){return this.is("."+selector);
},val:function(value){if(value==undefined){if(this.length){var elem=this[0];
if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";
if(index<0){return null;
}for(var i=one?index:0,max=one?index+1:options.length;
i<max;
i++){var option=options[i];
if(option.selected){value=jQuery.browser.msie&&!option.attributes.value.specified?option.text:option.value;
if(one){return value;
}values.push(value);
}}return values;
}else{return(this[0].value||"").replace(/\r/g,"");
}}return undefined;
}if(value.constructor==Number){value+="";
}return this.each(function(){if(this.nodeType!=1){return ;
}if(value.constructor==Array&&/radio|checkbox/.test(this.type)){this.checked=(jQuery.inArray(this.value,value)>=0||jQuery.inArray(this.name,value)>=0);
}else{if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(value);
jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);
});
if(!values.length){this.selectedIndex=-1;
}}else{this.value=value;
}}});
},html:function(value){return value==undefined?(this[0]?this[0].innerHTML:null):this.empty().append(value);
},replaceWith:function(value){return this.after(value).remove();
},eq:function(i){return this.slice(i,i+1);
},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));
},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);
}));
},andSelf:function(){return this.add(this.prevObject);
},data:function(key,value){var parts=key.split(".");
parts[1]=parts[1]?"."+parts[1]:"";
if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);
if(data===undefined&&this.length){data=jQuery.data(this[0],key);
}return data===undefined&&parts[1]?this.data(parts[0]):data;
}else{return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);
});
}},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);
});
},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;
return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);
if(reverse){elems.reverse();
}}var obj=this;
if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr")){obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));
}var scripts=jQuery([]);
jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;
if(jQuery.nodeName(elem,"script")){scripts=scripts.add(elem);
}else{if(elem.nodeType==1){scripts=scripts.add(jQuery("script",elem).remove());
}callback.call(obj,elem);
}});
scripts.each(evalScript);
});
}};
jQuery.fn.init.prototype=jQuery.fn;
function evalScript(i,elem){if(elem.src){jQuery.ajax({url:elem.src,async:false,dataType:"script"});
}else{jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");
}if(elem.parentNode){elem.parentNode.removeChild(elem);
}}function now(){return +new Date;
}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;
if(target.constructor==Boolean){deep=target;
target=arguments[1]||{};
i=2;
}if(typeof target!="object"&&typeof target!="function"){target={};
}if(length==i){target=this;
--i;
}for(;
i<length;
i++){if((options=arguments[i])!=null){for(var name in options){var src=target[name],copy=options[name];
if(target===copy){continue;
}if(deep&&copy&&typeof copy=="object"&&!copy.nodeType){target[name]=jQuery.extend(deep,src||(copy.length!=null?[]:{}),copy);
}else{if(copy!==undefined){target[name]=copy;
}}}}}return target;
};
var expando="jQuery"+now(),uuid=0,windowData={},exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i,defaultView=document.defaultView||{};
jQuery.extend({noConflict:function(deep){window.$=_$;
if(deep){window.jQuery=_jQuery;
}return jQuery;
},isFunction:function(fn){return !!fn&&typeof fn!="string"&&!fn.nodeName&&fn.constructor!=Array&&/^[\s[]?function/.test(fn+"");
},isXMLDoc:function(elem){return elem.documentElement&&!elem.body||elem.tagName&&elem.ownerDocument&&!elem.ownerDocument.body;
},globalEval:function(data){data=jQuery.trim(data);
if(data){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");
script.type="text/javascript";
if(jQuery.browser.msie){script.text=data;
}else{script.appendChild(document.createTextNode(data));
}head.insertBefore(script,head.firstChild);
head.removeChild(script);
}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();
},cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;
var id=elem[expando];
if(!id){id=elem[expando]=++uuid;
}if(name&&!jQuery.cache[id]){jQuery.cache[id]={};
}if(data!==undefined){jQuery.cache[id][name]=data;
}return name?jQuery.cache[id][name]:id;
},removeData:function(elem,name){elem=elem==window?windowData:elem;
var id=elem[expando];
if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];
name="";
for(name in jQuery.cache[id]){break;
}if(!name){jQuery.removeData(elem);
}}}else{try{delete elem[expando];
}catch(e){if(elem.removeAttribute){elem.removeAttribute(expando);
}}delete jQuery.cache[id];
}},each:function(object,callback,args){var name,i=0,length=object.length;
if(args){if(length==undefined){for(name in object){if(callback.apply(object[name],args)===false){break;
}}}else{for(;
i<length;
){if(callback.apply(object[i++],args)===false){break;
}}}}else{if(length==undefined){for(name in object){if(callback.call(object[name],name,object[name])===false){break;
}}}else{for(var value=object[0];
i<length&&callback.call(value,i,value)!==false;
value=object[++i]){}}}return object;
},prop:function(elem,value,type,i,name){if(jQuery.isFunction(value)){value=value.call(elem,i);
}return value&&value.constructor==Number&&type=="curCSS"&&!exclude.test(name)?value+"px":value;
},className:{add:function(elem,classNames){jQuery.each((classNames||"").split(/\s+/),function(i,className){if(elem.nodeType==1&&!jQuery.className.has(elem.className,className)){elem.className+=(elem.className?" ":"")+className;
}});
},remove:function(elem,classNames){if(elem.nodeType==1){elem.className=classNames!=undefined?jQuery.grep(elem.className.split(/\s+/),function(className){return !jQuery.className.has(classNames,className);
}).join(" "):"";
}},has:function(elem,className){return jQuery.inArray(className,(elem.className||elem).toString().split(/\s+/))>-1;
}},swap:function(elem,options,callback){var old={};
for(var name in options){old[name]=elem.style[name];
elem.style[name]=options[name];
}callback.call(elem);
for(var name in options){elem.style[name]=old[name];
}},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];
function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;
var padding=0,border=0;
jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;
border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;
});
val-=Math.round(padding+border);
}if(jQuery(elem).is(":visible")){getWH();
}else{jQuery.swap(elem,props,getWH);
}return Math.max(0,val);
}return jQuery.curCSS(elem,name,force);
},curCSS:function(elem,name,force){var ret,style=elem.style;
function color(elem){if(!jQuery.browser.safari){return false;
}var ret=defaultView.getComputedStyle(elem,null);
return !ret||ret.getPropertyValue("color")=="";
}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(style,"opacity");
return ret==""?"1":ret;
}if(jQuery.browser.opera&&name=="display"){var save=style.outline;
style.outline="0 solid black";
style.outline=save;
}if(name.match(/float/i)){name=styleFloat;
}if(!force&&style&&style[name]){ret=style[name];
}else{if(defaultView.getComputedStyle){if(name.match(/float/i)){name="float";
}name=name.replace(/([A-Z])/g,"-$1").toLowerCase();
var computedStyle=defaultView.getComputedStyle(elem,null);
if(computedStyle&&!color(elem)){ret=computedStyle.getPropertyValue(name);
}else{var swap=[],stack=[],a=elem,i=0;
for(;
a&&color(a);
a=a.parentNode){stack.unshift(a);
}for(;
i<stack.length;
i++){if(color(stack[i])){swap[i]=stack[i].style.display;
stack[i].style.display="block";
}}ret=name=="display"&&swap[stack.length-1]!=null?"none":(computedStyle&&computedStyle.getPropertyValue(name))||"";
for(i=0;
i<swap.length;
i++){if(swap[i]!=null){stack[i].style.display=swap[i];
}}}if(name=="opacity"&&ret==""){ret="1";
}}else{if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();
});
ret=elem.currentStyle[name]||elem.currentStyle[camelCase];
if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;
elem.runtimeStyle.left=elem.currentStyle.left;
style.left=ret||0;
ret=style.pixelLeft+"px";
style.left=left;
elem.runtimeStyle.left=rsLeft;
}}}}return ret;
},clean:function(elems,context){var ret=[];
context=context||document;
if(typeof context.createElement=="undefined"){context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;
}jQuery.each(elems,function(i,elem){if(!elem){return ;
}if(elem.constructor==Number){elem+="";
}if(typeof elem=="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+"></"+tag+">";
});
var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");
var wrap=!tags.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!tags.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!tags.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!tags.indexOf("<td")||!tags.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!tags.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||jQuery.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];
div.innerHTML=wrap[1]+elem+wrap[2];
while(wrap[0]--){div=div.lastChild;
}if(jQuery.browser.msie){var tbody=!tags.indexOf("<table")&&tags.indexOf("<tbody")<0?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&tags.indexOf("<tbody")<0?div.childNodes:[];
for(var j=tbody.length-1;
j>=0;
--j){if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length){tbody[j].parentNode.removeChild(tbody[j]);
}}if(/^\s/.test(elem)){div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);
}}elem=jQuery.makeArray(div.childNodes);
}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select"))){return ;
}if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options){ret.push(elem);
}else{ret=jQuery.merge(ret,elem);
}});
return ret;
},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8){return undefined;
}var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined,msie=jQuery.browser.msie;
name=notxml&&jQuery.props[name]||name;
if(elem.tagName){var special=/href|src|style/.test(name);
if(name=="selected"&&jQuery.browser.safari){elem.parentNode.selectedIndex;
}if(name in elem&&notxml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode){throw"type property can't be changed";
}elem[name]=value;
}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name)){return elem.getAttributeNode(name).nodeValue;
}return elem[name];
}if(msie&&notxml&&name=="style"){return jQuery.attr(elem.style,"cssText",value);
}if(set){elem.setAttribute(name,""+value);
}var attr=msie&&notxml&&special?elem.getAttribute(name,2):elem.getAttribute(name);
return attr===null?undefined:attr;
}if(msie&&name=="opacity"){if(set){elem.zoom=1;
elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(value)+""=="NaN"?"":"alpha(opacity="+value*100+")");
}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+"":"";
}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();
});
if(set){elem[name]=value;
}return elem[name];
},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");
},makeArray:function(array){var ret=[];
if(array!=null){var i=array.length;
if(i==null||array.split||array.setInterval||array.call){ret[0]=array;
}else{while(i){ret[--i]=array[i];
}}}return ret;
},inArray:function(elem,array){for(var i=0,length=array.length;
i<length;
i++){if(array[i]===elem){return i;
}}return -1;
},merge:function(first,second){var i=0,elem,pos=first.length;
if(jQuery.browser.msie){while(elem=second[i++]){if(elem.nodeType!=8){first[pos++]=elem;
}}}else{while(elem=second[i++]){first[pos++]=elem;
}}return first;
},unique:function(array){var ret=[],done={};
try{for(var i=0,length=array.length;
i<length;
i++){var id=jQuery.data(array[i]);
if(!done[id]){done[id]=true;
ret.push(array[i]);
}}}catch(e){ret=array;
}return ret;
},grep:function(elems,callback,inv){var ret=[];
for(var i=0,length=elems.length;
i<length;
i++){if(!inv!=!callback(elems[i],i)){ret.push(elems[i]);
}}return ret;
},map:function(elems,callback){var ret=[];
for(var i=0,length=elems.length;
i<length;
i++){var value=callback(elems[i],i);
if(value!=null){ret[ret.length]=value;
}}return ret.concat.apply([],ret);
}});
var userAgent=navigator.userAgent.toLowerCase();
jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};
var styleFloat=jQuery.browser.msie?"styleFloat":"cssFloat";
jQuery.extend({boxModel:!jQuery.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing"}});
jQuery.each({parent:function(elem){return elem.parentNode;
},parents:function(elem){return jQuery.dir(elem,"parentNode");
},next:function(elem){return jQuery.nth(elem,2,"nextSibling");
},prev:function(elem){return jQuery.nth(elem,2,"previousSibling");
},nextAll:function(elem){return jQuery.dir(elem,"nextSibling");
},prevAll:function(elem){return jQuery.dir(elem,"previousSibling");
},siblings:function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);
},children:function(elem){return jQuery.sibling(elem.firstChild);
},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);
}},function(name,fn){jQuery.fn[name]=function(selector){var ret=jQuery.map(this,fn);
if(selector&&typeof selector=="string"){ret=jQuery.multiFilter(selector,ret);
}return this.pushStack(jQuery.unique(ret));
};
});
jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(){var args=arguments;
return this.each(function(){for(var i=0,length=args.length;
i<length;
i++){jQuery(args[i])[original](this);
}});
};
});
jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");
if(this.nodeType==1){this.removeAttribute(name);
}},addClass:function(classNames){jQuery.className.add(this,classNames);
},removeClass:function(classNames){jQuery.className.remove(this,classNames);
},toggleClass:function(classNames){jQuery.className[jQuery.className.has(this,classNames)?"remove":"add"](this,classNames);
},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).r.length){jQuery("*",this).add(this).each(function(){jQuery.event.remove(this);
jQuery.removeData(this);
});
if(this.parentNode){this.parentNode.removeChild(this);
}}},empty:function(){jQuery(">*",this).remove();
while(this.firstChild){this.removeChild(this.firstChild);
}}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);
};
});
jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();
jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");
};
});
function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;
}var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");
jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);
},"#":function(a,i,m){return a.getAttribute("id")==m[2];
},":":{lt:function(a,i,m){return i<m[3]-0;
},gt:function(a,i,m){return i>m[3]-0;
},nth:function(a,i,m){return m[3]-0==i;
},eq:function(a,i,m){return m[3]-0==i;
},first:function(a,i){return i==0;
},last:function(a,i,m,r){return i==r.length-1;
},even:function(a,i){return i%2==0;
},odd:function(a,i){return i%2;
},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;
},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;
},"only-child":function(a){return !jQuery.nth(a.parentNode.lastChild,2,"previousSibling");
},parent:function(a){return a.firstChild;
},empty:function(a){return !a.firstChild;
},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;
},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";
},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";
},enabled:function(a){return !a.disabled;
},disabled:function(a){return a.disabled;
},checked:function(a){return a.checked;
},selected:function(a){return a.selected||jQuery.attr(a,"selected");
},text:function(a){return"text"==a.type;
},radio:function(a){return"radio"==a.type;
},checkbox:function(a){return"checkbox"==a.type;
},file:function(a){return"file"==a.type;
},password:function(a){return"password"==a.type;
},submit:function(a){return"submit"==a.type;
},image:function(a){return"image"==a.type;
},reset:function(a){return"reset"==a.type;
},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");
},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);
},has:function(a,i,m){return jQuery.find(m[3],a).length;
},header:function(a){return/h\d/i.test(a.nodeName);
},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;
}).length;
}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];
while(expr&&expr!=old){old=expr;
var f=jQuery.filter(expr,elems,not);
expr=f.t.replace(/^\s*,\s*/,"");
cur=not?elems=f.r:jQuery.merge(cur,f.r);
}return cur;
},find:function(t,context){if(typeof t!="string"){return[t];
}if(context&&context.nodeType!=1&&context.nodeType!=9){return[];
}context=context||document;
var ret=[context],done=[],last,nodeName;
while(t&&last!=t){var r=[];
last=t;
t=jQuery.trim(t);
var foundToken=false,re=quickChild,m=re.exec(t);
if(m){nodeName=m[1].toUpperCase();
for(var i=0;
ret[i];
i++){for(var c=ret[i].firstChild;
c;
c=c.nextSibling){if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName)){r.push(c);
}}}ret=r;
t=t.replace(re,"");
if(t.indexOf(" ")==0){continue;
}foundToken=true;
}else{re=/^([>+~])\s*(\w*)/i;
if((m=re.exec(t))!=null){r=[];
var merge={};
nodeName=m[2].toUpperCase();
m=m[1];
for(var j=0,rl=ret.length;
j<rl;
j++){var n=m=="~"||m=="+"?ret[j].nextSibling:ret[j].firstChild;
for(;
n;
n=n.nextSibling){if(n.nodeType==1){var id=jQuery.data(n);
if(m=="~"&&merge[id]){break;
}if(!nodeName||n.nodeName.toUpperCase()==nodeName){if(m=="~"){merge[id]=true;
}r.push(n);
}if(m=="+"){break;
}}}}ret=r;
t=jQuery.trim(t.replace(re,""));
foundToken=true;
}}if(t&&!foundToken){if(!t.indexOf(",")){if(context==ret[0]){ret.shift();
}done=jQuery.merge(done,ret);
r=ret=[context];
t=" "+t.substr(1,t.length);
}else{var re2=quickID;
var m=re2.exec(t);
if(m){m=[0,m[2],m[3],m[1]];
}else{re2=quickClass;
m=re2.exec(t);
}m[2]=m[2].replace(/\\/g,"");
var elem=ret[ret.length-1];
if(m[1]=="#"&&elem&&elem.getElementById&&!jQuery.isXMLDoc(elem)){var oid=elem.getElementById(m[2]);
if((jQuery.browser.msie||jQuery.browser.opera)&&oid&&typeof oid.id=="string"&&oid.id!=m[2]){oid=jQuery('[@id="'+m[2]+'"]',elem)[0];
}ret=r=oid&&(!m[3]||jQuery.nodeName(oid,m[3]))?[oid]:[];
}else{for(var i=0;
ret[i];
i++){var tag=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];
if(tag=="*"&&ret[i].nodeName.toLowerCase()=="object"){tag="param";
}r=jQuery.merge(r,ret[i].getElementsByTagName(tag));
}if(m[1]=="."){r=jQuery.classFilter(r,m[2]);
}if(m[1]=="#"){var tmp=[];
for(var i=0;
r[i];
i++){if(r[i].getAttribute("id")==m[2]){tmp=[r[i]];
break;
}}r=tmp;
}ret=r;
}t=t.replace(re2,"");
}}if(t){var val=jQuery.filter(t,r);
ret=r=val.r;
t=jQuery.trim(val.t);
}}if(t){ret=[];
}if(ret&&context==ret[0]){ret.shift();
}done=jQuery.merge(done,ret);
return done;
},classFilter:function(r,m,not){m=" "+m+" ";
var tmp=[];
for(var i=0;
r[i];
i++){var pass=(" "+r[i].className+" ").indexOf(m)>=0;
if(!not&&pass||not&&!pass){tmp.push(r[i]);
}}return tmp;
},filter:function(t,r,not){var last;
while(t&&t!=last){last=t;
var p=jQuery.parse,m;
for(var i=0;
p[i];
i++){m=p[i].exec(t);
if(m){t=t.substring(m[0].length);
m[2]=m[2].replace(/\\/g,"");
break;
}}if(!m){break;
}if(m[1]==":"&&m[2]=="not"){r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);
}else{if(m[1]=="."){r=jQuery.classFilter(r,m[2],not);
}else{if(m[1]=="["){var tmp=[],type=m[3];
for(var i=0,rl=r.length;
i<rl;
i++){var a=r[i],z=a[jQuery.props[m[2]]||m[2]];
if(z==null||/href|src|selected/.test(m[2])){z=jQuery.attr(a,m[2])||"";
}if((type==""&&!!z||type=="="&&z==m[5]||type=="!="&&z!=m[5]||type=="^="&&z&&!z.indexOf(m[5])||type=="$="&&z.substr(z.length-m[5].length)==m[5]||(type=="*="||type=="~=")&&z.indexOf(m[5])>=0)^not){tmp.push(a);
}}r=tmp;
}else{if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;
for(var i=0,rl=r.length;
i<rl;
i++){var node=r[i],parentNode=node.parentNode,id=jQuery.data(parentNode);
if(!merge[id]){var c=1;
for(var n=parentNode.firstChild;
n;
n=n.nextSibling){if(n.nodeType==1){n.nodeIndex=c++;
}}merge[id]=true;
}var add=false;
if(first==0){if(node.nodeIndex==last){add=true;
}}else{if((node.nodeIndex-last)%first==0&&(node.nodeIndex-last)/first>=0){add=true;
}}if(add^not){tmp.push(node);
}}r=tmp;
}else{var fn=jQuery.expr[m[1]];
if(typeof fn=="object"){fn=fn[m[2]];
}if(typeof fn=="string"){fn=eval("false||function(a,i){return "+fn+";}");
}r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);
},not);
}}}}}return{r:r,t:t};
},dir:function(elem,dir){var matched=[],cur=elem[dir];
while(cur&&cur!=document){if(cur.nodeType==1){matched.push(cur);
}cur=cur[dir];
}return matched;
},nth:function(cur,result,dir,elem){result=result||1;
var num=0;
for(;
cur;
cur=cur[dir]){if(cur.nodeType==1&&++num==result){break;
}}return cur;
},sibling:function(n,elem){var r=[];
for(;
n;
n=n.nextSibling){if(n.nodeType==1&&n!=elem){r.push(n);
}}return r;
}});
jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8){return ;
}if(jQuery.browser.msie&&elem.setInterval){elem=window;
}if(!handler.guid){handler.guid=this.guid++;
}if(data!=undefined){var fn=handler;
handler=this.proxy(fn,function(){return fn.apply(this,arguments);
});
handler.data=data;
}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){if(typeof jQuery!="undefined"&&!jQuery.event.triggered){return jQuery.event.handle.apply(arguments.callee.elem,arguments);
}});
handle.elem=elem;
jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");
type=parts[0];
handler.type=parts[1];
var handlers=events[type];
if(!handlers){handlers=events[type]={};
if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener){elem.addEventListener(type,handle,false);
}else{if(elem.attachEvent){elem.attachEvent("on"+type,handle);
}}}}handlers[handler.guid]=handler;
jQuery.event.global[type]=true;
});
elem=null;
},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8){return ;
}var events=jQuery.data(elem,"events"),ret,index;
if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)==".")){for(var type in events){this.remove(elem,type+(types||""));
}}else{if(types.type){handler=types.handler;
types=types.type;
}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");
type=parts[0];
if(events[type]){if(handler){delete events[type][handler.guid];
}else{for(handler in events[type]){if(!parts[1]||events[type][handler].type==parts[1]){delete events[type][handler];
}}}for(ret in events[type]){break;
}if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener){elem.removeEventListener(type,jQuery.data(elem,"handle"),false);
}else{if(elem.detachEvent){elem.detachEvent("on"+type,jQuery.data(elem,"handle"));
}}}ret=null;
delete events[type];
}}});
}for(ret in events){break;
}if(!ret){var handle=jQuery.data(elem,"handle");
if(handle){handle.elem=null;
}jQuery.removeData(elem,"events");
jQuery.removeData(elem,"handle");
}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data);
if(type.indexOf("!")>=0){type=type.slice(0,-1);
var exclusive=true;
}if(!elem){if(this.global[type]){jQuery("*").add([window,document]).trigger(type,data);
}}else{if(elem.nodeType==3||elem.nodeType==8){return undefined;
}var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;
if(event){data.unshift({type:type,target:elem,preventDefault:function(){},stopPropagation:function(){},timeStamp:now()});
data[0][expando]=true;
}data[0].type=type;
if(exclusive){data[0].exclusive=true;
}var handle=jQuery.data(elem,"handle");
if(handle){val=handle.apply(elem,data);
}if((!fn||(jQuery.nodeName(elem,"a")&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false){val=false;
}if(event){data.shift();
}if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));
if(ret!==undefined){val=ret;
}}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,"a")&&type=="click")){this.triggered=true;
try{elem[type]();
}catch(e){}}this.triggered=false;
}return val;
},handle:function(event){var val,ret,namespace,all,handlers;
event=arguments[0]=jQuery.event.fix(event||window.event);
namespace=event.type.split(".");
event.type=namespace[0];
namespace=namespace[1];
all=!namespace&&!event.exclusive;
handlers=(jQuery.data(this,"events")||{})[event.type];
for(var j in handlers){var handler=handlers[j];
if(all||handler.type==namespace){event.handler=handler;
event.data=handler.data;
ret=handler.apply(this,arguments);
if(val!==false){val=ret;
}if(ret===false){event.preventDefault();
event.stopPropagation();
}}}return val;
},fix:function(event){if(event[expando]==true){return event;
}var originalEvent=event;
event={originalEvent:originalEvent};
var props="altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" ");
for(var i=props.length;
i;
i--){event[props[i]]=originalEvent[props[i]];
}event[expando]=true;
event.preventDefault=function(){if(originalEvent.preventDefault){originalEvent.preventDefault();
}originalEvent.returnValue=false;
};
event.stopPropagation=function(){if(originalEvent.stopPropagation){originalEvent.stopPropagation();
}originalEvent.cancelBubble=true;
};
event.timeStamp=event.timeStamp||now();
if(!event.target){event.target=event.srcElement||document;
}if(event.target.nodeType==3){event.target=event.target.parentNode;
}if(!event.relatedTarget&&event.fromElement){event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;
}if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;
event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);
event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);
}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode)){event.which=event.charCode||event.keyCode;
}if(!event.metaKey&&event.ctrlKey){event.metaKey=event.ctrlKey;
}if(!event.which&&event.button){event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));
}return event;
},proxy:function(fn,proxy){proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;
return proxy;
},special:{ready:{setup:function(){bindReady();
return ;
},teardown:function(){return ;
}},mouseenter:{setup:function(){if(jQuery.browser.msie){return false;
}jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);
return true;
},teardown:function(){if(jQuery.browser.msie){return false;
}jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);
return true;
},handler:function(event){if(withinElement(event,this)){return true;
}event.type="mouseenter";
return jQuery.event.handle.apply(this,arguments);
}},mouseleave:{setup:function(){if(jQuery.browser.msie){return false;
}jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);
return true;
},teardown:function(){if(jQuery.browser.msie){return false;
}jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);
return true;
},handler:function(event){if(withinElement(event,this)){return true;
}event.type="mouseleave";
return jQuery.event.handle.apply(this,arguments);
}}}};
jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);
});
},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);
return(fn||data).apply(this,arguments);
});
return this.each(function(){jQuery.event.add(this,type,one,fn&&data);
});
},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);
});
},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);
});
},triggerHandler:function(type,data,fn){return this[0]&&jQuery.event.trigger(type,data,this[0],false,fn);
},toggle:function(fn){var args=arguments,i=1;
while(i<args.length){jQuery.event.proxy(fn,args[i++]);
}return this.click(jQuery.event.proxy(fn,function(event){this.lastToggle=(this.lastToggle||0)%i;
event.preventDefault();
return args[this.lastToggle++].apply(this,arguments)||false;
}));
},hover:function(fnOver,fnOut){return this.bind("mouseenter",fnOver).bind("mouseleave",fnOut);
},ready:function(fn){bindReady();
if(jQuery.isReady){fn.call(document,jQuery);
}else{jQuery.readyList.push(function(){return fn.call(this,jQuery);
});
}return this;
}});
jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;
if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.call(document);
});
jQuery.readyList=null;
}jQuery(document).triggerHandler("ready");
}}});
var readyBound=false;
function bindReady(){if(readyBound){return ;
}readyBound=true;
if(document.addEventListener&&!jQuery.browser.opera){document.addEventListener("DOMContentLoaded",jQuery.ready,false);
}if(jQuery.browser.msie&&window==top){(function(){if(jQuery.isReady){return ;
}try{document.documentElement.doScroll("left");
}catch(error){setTimeout(arguments.callee,0);
return ;
}jQuery.ready();
})();
}if(jQuery.browser.opera){document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady){return ;
}for(var i=0;
i<document.styleSheets.length;
i++){if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);
return ;
}}jQuery.ready();
},false);
}if(jQuery.browser.safari){var numStyles;
(function(){if(jQuery.isReady){return ;
}if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);
return ;
}if(numStyles===undefined){numStyles=jQuery("style, link[rel=stylesheet]").length;
}if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);
return ;
}jQuery.ready();
})();
}jQuery.event.add(window,"load",jQuery.ready);
}jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,change,select,submit,keydown,keypress,keyup,error").split(","),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name);
};
});
var withinElement=function(event,elem){var parent=event.relatedTarget;
while(parent&&parent!=elem){try{parent=parent.parentNode;
}catch(error){parent=elem;
}}return parent==elem;
};
jQuery(window).bind("unload",function(){jQuery("*").add(document).unbind();
});
jQuery.fn.extend({_load:jQuery.fn.load,load:function(url,params,callback){if(typeof url!="string"){return this._load(url);
}var off=url.indexOf(" ");
if(off>=0){var selector=url.slice(off,url.length);
url=url.slice(0,off);
}callback=callback||function(){};
var type="GET";
if(params){if(jQuery.isFunction(params)){callback=params;
params=null;
}else{params=jQuery.param(params);
type="POST";
}}var self=this;
jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified"){self.html(selector?jQuery("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(selector):res.responseText);
}self.each(callback,[res.responseText,status,res]);
}});
return this;
},serialize:function(){return jQuery.param(this.serializeArray());
},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;
}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));
}).map(function(i,elem){var val=jQuery(this).val();
return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};
}):{name:elem.name,value:val};
}).get();
}});
jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);
};
});
var jsc=now();
jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;
data=null;
}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});
},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");
},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");
},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;
data={};
}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});
},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);
},ajaxSettings:{url:location.href,global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));
var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();
if(s.data&&s.processData&&typeof s.data!="string"){s.data=jQuery.param(s.data);
}if(s.dataType=="jsonp"){if(type=="GET"){if(!s.url.match(jsre)){s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";
}}else{if(!s.data||!s.data.match(jsre)){s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";
}}s.dataType="json";
}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;
if(s.data){s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");
}s.url=s.url.replace(jsre,"="+jsonp+"$1");
s.dataType="script";
window[jsonp]=function(tmp){data=tmp;
success();
complete();
window[jsonp]=undefined;
try{delete window[jsonp];
}catch(e){}if(head){head.removeChild(script);
}};
}if(s.dataType=="script"&&s.cache==null){s.cache=false;
}if(s.cache===false&&type=="GET"){var ts=now();
var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");
s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");
}if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;
s.data=null;
}if(s.global&&!jQuery.active++){jQuery.event.trigger("ajaxStart");
}var remote=/^(?:\w+:)?\/\/([^\/?#]+)/;
if(s.dataType=="script"&&type=="GET"&&remote.test(s.url)&&remote.exec(s.url)[1]!=location.host){var head=document.getElementsByTagName("head")[0];
var script=document.createElement("script");
script.src=s.url;
if(s.scriptCharset){script.charset=s.scriptCharset;
}if(!jsonp){var done=false;
script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;
success();
complete();
head.removeChild(script);
}};
}head.appendChild(script);
return undefined;
}var requestDone=false;
var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
if(s.username){xhr.open(type,s.url,s.async,s.username,s.password);
}else{xhr.open(type,s.url,s.async);
}try{if(s.data){xhr.setRequestHeader("Content-Type",s.contentType);
}if(s.ifModified){xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");
}xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");
xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);
}catch(e){}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;
xhr.abort();
return false;
}if(s.global){jQuery.event.trigger("ajaxSend",[xhr,s]);
}var onreadystatechange=function(isTimeout){if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;
if(ival){clearInterval(ival);
ival=null;
}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xhr)&&"error"||s.ifModified&&jQuery.httpNotModified(xhr,s.url)&&"notmodified"||"success";
if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s.dataFilter);
}catch(e){status="parsererror";
}}if(status=="success"){var modRes;
try{modRes=xhr.getResponseHeader("Last-Modified");
}catch(e){}if(s.ifModified&&modRes){jQuery.lastModified[s.url]=modRes;
}if(!jsonp){success();
}}else{jQuery.handleError(s,xhr,status);
}complete();
if(s.async){xhr=null;
}}};
if(s.async){var ival=setInterval(onreadystatechange,13);
if(s.timeout>0){setTimeout(function(){if(xhr){xhr.abort();
if(!requestDone){onreadystatechange("timeout");
}}},s.timeout);
}}try{xhr.send(s.data);
}catch(e){jQuery.handleError(s,xhr,null,e);
}if(!s.async){onreadystatechange();
}function success(){if(s.success){s.success(data,status);
}if(s.global){jQuery.event.trigger("ajaxSuccess",[xhr,s]);
}}function complete(){if(s.complete){s.complete(xhr,status);
}if(s.global){jQuery.event.trigger("ajaxComplete",[xhr,s]);
}if(s.global&&!--jQuery.active){jQuery.event.trigger("ajaxStop");
}}return xhr;
},handleError:function(s,xhr,status,e){if(s.error){s.error(xhr,status,e);
}if(s.global){jQuery.event.trigger("ajaxError",[xhr,s,e]);
}},active:0,httpSuccess:function(xhr){try{return !xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223||jQuery.browser.safari&&xhr.status==undefined;
}catch(e){}return false;
},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");
return xhr.status==304||xhrRes==jQuery.lastModified[url]||jQuery.browser.safari&&xhr.status==undefined;
}catch(e){}return false;
},httpData:function(xhr,type,filter){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;
if(xml&&data.documentElement.tagName=="parsererror"){throw"parsererror";
}if(filter){data=filter(data,type);
}if(type=="script"){jQuery.globalEval(data);
}if(type=="json"){data=eval("("+data+")");
}return data;
},param:function(a){var s=[];
if(a.constructor==Array||a.jquery){jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));
});
}else{for(var j in a){if(a[j]&&a[j].constructor==Array){jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));
});
}else{s.push(encodeURIComponent(j)+"="+encodeURIComponent(jQuery.isFunction(a[j])?a[j]():a[j]));
}}}return s.join("&").replace(/%20/g,"+");
}});
jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";
if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");
this.style.display=elem.css("display");
if(this.style.display=="none"){this.style.display="block";
}elem.remove();
}}).end();
},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");
this.style.display="none";
}).end();
},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle.apply(this,arguments):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();
});
},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);
},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);
},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);
},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);
},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);
},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);
},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);
return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1){return false;
}var opt=jQuery.extend({},optall),p,hidden=jQuery(this).is(":hidden"),self=this;
for(p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden){return opt.complete.call(this);
}if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");
opt.overflow=this.style.overflow;
}}if(opt.overflow!=null){this.style.overflow="hidden";
}opt.curAnim=jQuery.extend({},prop);
jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);
if(/toggle|show|hide/.test(val)){e[val=="toggle"?hidden?"show":"hide":val](prop);
}else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;
if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";
if(unit!="px"){self.style[name]=(end||1)+unit;
start=((end||1)/e.cur(true))*start;
self.style[name]=start+unit;
}if(parts[1]){end=((parts[1]=="-="?-1:1)*end)+start;
}e.custom(start,end,unit);
}else{e.custom(start,val,"");
}}});
return true;
});
},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;
type="fx";
}if(!type||(typeof type=="string"&&!fn)){return queue(this[0],type);
}return this.each(function(){if(fn.constructor==Array){queue(this,type,fn);
}else{queue(this,type).push(fn);
if(queue(this,type).length==1){fn.call(this);
}}});
},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;
if(clearQueue){this.queue([]);
}this.each(function(){for(var i=timers.length-1;
i>=0;
i--){if(timers[i].elem==this){if(gotoEnd){timers[i](true);
}timers.splice(i,1);
}}});
if(!gotoEnd){this.dequeue();
}return this;
}});
var queue=function(elem,type,array){if(elem){type=type||"fx";
var q=jQuery.data(elem,type+"queue");
if(!q||array){q=jQuery.data(elem,type+"queue",jQuery.makeArray(array));
}}return q;
};
jQuery.fn.dequeue=function(type){type=type||"fx";
return this.each(function(){var q=queue(this,type);
q.shift();
if(q.length){q[0].call(this);
}});
};
jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};
opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:jQuery.fx.speeds[opt.duration])||jQuery.fx.speeds.def;
opt.old=opt.complete;
opt.complete=function(){if(opt.queue!==false){jQuery(this).dequeue();
}if(jQuery.isFunction(opt.old)){opt.old.call(this);
}};
return opt;
},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;
},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;
}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;
this.elem=elem;
this.prop=prop;
if(!options.orig){options.orig={};
}}});
jQuery.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this);
}(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);
if(this.prop=="height"||this.prop=="width"){this.elem.style.display="block";
}},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null){return this.elem[this.prop];
}var r=parseFloat(jQuery.css(this.elem,this.prop,force));
return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;
},custom:function(from,to,unit){this.startTime=now();
this.start=from;
this.end=to;
this.unit=unit||this.unit||"px";
this.now=this.start;
this.pos=this.state=0;
this.update();
var self=this;
function t(gotoEnd){return self.step(gotoEnd);
}t.elem=this.elem;
jQuery.timers.push(t);
if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;
for(var i=0;
i<timers.length;
i++){if(!timers[i]()){timers.splice(i--,1);
}}if(!timers.length){clearInterval(jQuery.timerId);
jQuery.timerId=null;
}},13);
}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);
this.options.show=true;
this.custom(0,this.cur());
if(this.prop=="width"||this.prop=="height"){this.elem.style[this.prop]="1px";
}jQuery(this.elem).show();
},hide:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);
this.options.hide=true;
this.custom(this.cur(),0);
},step:function(gotoEnd){var t=now();
if(gotoEnd||t>this.options.duration+this.startTime){this.now=this.end;
this.pos=this.state=1;
this.update();
this.options.curAnim[this.prop]=true;
var done=true;
for(var i in this.options.curAnim){if(this.options.curAnim[i]!==true){done=false;
}}if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;
this.elem.style.display=this.options.display;
if(jQuery.css(this.elem,"display")=="none"){this.elem.style.display="block";
}}if(this.options.hide){this.elem.style.display="none";
}if(this.options.hide||this.options.show){for(var p in this.options.curAnim){jQuery.attr(this.elem.style,p,this.options.orig[p]);
}}}if(done){this.options.complete.call(this.elem);
}return false;
}else{var n=t-this.startTime;
this.state=n/this.options.duration;
this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);
this.now=this.start+((this.end-this.start)*this.pos);
this.update();
}return true;
}};
jQuery.extend(jQuery.fx,{speeds:{slow:600,fast:200,def:400},step:{scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;
},scrollTop:function(fx){fx.elem.scrollTop=fx.now;
},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);
},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;
}}});
jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;
if(elem){with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522&&!/adobeair/i.test(userAgent),css=jQuery.curCSS,fixed=css(elem,"position")=="fixed";
if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();
add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));
add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);
}else{add(elem.offsetLeft,elem.offsetTop);
while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);
if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2){border(offsetParent);
}if(!fixed&&css(offsetParent,"position")=="fixed"){fixed=true;
}offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;
offsetParent=offsetParent.offsetParent;
}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(css(parent,"display"))){add(-parent.scrollLeft,-parent.scrollTop);
}if(mozilla&&css(parent,"overflow")!="visible"){border(parent);
}parent=parent.parentNode;
}if((safari2&&(fixed||css(offsetChild,"position")=="absolute"))||(mozilla&&css(offsetChild,"position")!="absolute")){add(-doc.body.offsetLeft,-doc.body.offsetTop);
}if(fixed){add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));
}}results={top:top,left:left};
}}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));
}function add(l,t){left+=parseInt(l,10)||0;
top+=parseInt(t,10)||0;
}return results;
};
jQuery.fn.extend({position:function(){var left=0,top=0,results;
if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();
offset.top-=num(this,"marginTop");
offset.left-=num(this,"marginLeft");
parentOffset.top+=num(offsetParent,"borderTopWidth");
parentOffset.left+=num(offsetParent,"borderLeftWidth");
results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};
}return results;
},offsetParent:function(){var offsetParent=this[0].offsetParent;
while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,"position")=="static")){offsetParent=offsetParent.offsetParent;
}return jQuery(offsetParent);
}});
jQuery.each(["Left","Top"],function(i,name){var method="scroll"+name;
jQuery.fn[method]=function(val){if(!this[0]){return ;
}return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;
}):this[0]==window||this[0]==document?self[i?"pageYOffset":"pageXOffset"]||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];
};
});
jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom";
jQuery.fn["inner"+name]=function(){return this[name.toLowerCase()]()+num(this,"padding"+tl)+num(this,"padding"+br);
};
jQuery.fn["outer"+name]=function(margin){return this["inner"+name]()+num(this,"border"+tl+"Width")+num(this,"border"+br+"Width")+(margin?num(this,"margin"+tl)+num(this,"margin"+br):0);
};
});
})();


/* json2.js */
if(!this.JSON){JSON=function(){function f(n){return n<10?"0"+n:n;
}Date.prototype.toJSON=function(key){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z";
};
String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();
};
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapeable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;
function quote(string){escapeable.lastIndex=0;
return escapeable.test(string)?'"'+string.replace(escapeable,function(a){var c=meta[a];
if(typeof c==="string"){return c;
}return"\\u"+("0000"+(+(a.charCodeAt(0))).toString(16)).slice(-4);
})+'"':'"'+string+'"';
}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];
if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key);
}if(typeof rep==="function"){value=rep.call(holder,key,value);
}switch(typeof value){case"string":return quote(value);
case"number":return isFinite(value)?String(value):"null";
case"boolean":case"null":return String(value);
case"object":if(!value){return"null";
}gap+=indent;
partial=[];
if(typeof value.length==="number"&&!(value.propertyIsEnumerable("length"))){length=value.length;
for(i=0;
i<length;
i+=1){partial[i]=str(i,value)||"null";
}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";
gap=mind;
return v;
}if(rep&&typeof rep==="object"){length=rep.length;
for(i=0;
i<length;
i+=1){k=rep[i];
if(typeof k==="string"){v=str(k,value);
if(v){partial.push(quote(k)+(gap?": ":":")+v);
}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);
if(v){partial.push(quote(k)+(gap?": ":":")+v);
}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";
gap=mind;
return v;
}}return{stringify:function(value,replacer,space){var i;
gap="";
indent="";
if(typeof space==="number"){for(i=0;
i<space;
i+=1){indent+=" ";
}}else{if(typeof space==="string"){indent=space;
}}rep=replacer;
if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify");
}return str("",{"":value});
},parse:function(text,reviver){var j;
function walk(holder,key){var k,v,value=holder[key];
if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);
if(v!==undefined){value[k]=v;
}else{delete value[k];
}}}}return reviver.call(holder,key,value);
}cx.lastIndex=0;
if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+(+(a.charCodeAt(0))).toString(16)).slice(-4);
});
}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");
return typeof reviver==="function"?walk({"":j},""):j;
}throw new SyntaxError("JSON.parse");
}};
}();
}

/* rison.js */
if(typeof rison=="undefined"){window.rison={};
}rison.uri_ok={"~":true,"!":true,"*":true,"(":true,")":true,"-":true,"_":true,".":true,",":true,":":true,"@":true,"$":true,"'":true,"/":true};
(function(){var A=[];
for(var B=0;
B<16;
B++){for(var C=0;
C<16;
C++){if(B+C==0){continue;
}var D=String.fromCharCode(B*16+C);
if(!/\w|[-_.\/~]/.test(D)){A.push("\\u00"+B.toString(16)+C.toString(16));
}}}rison.not_idchar=A.join("");
})();
rison.not_idchar=" '!:(),*@$";
rison.not_idstart="-0123456789";
(function(){var A="[^"+rison.not_idstart+rison.not_idchar+"][^"+rison.not_idchar+"]*";
rison.id_ok=new RegExp("^"+A+"$");
rison.next_id=new RegExp(A,"g");
})();
rison.quote=function(A){var B=rison.uri_ok;
if(/^[A-Za-z0-9_-]*$/.test(A)){return A;
}A=A.replace(/([^A-Za-z0-9_-])/g,function(D,C){var E=B[C];
if(E){return C;
}return encodeURIComponent(C);
});
return A.replace(/%20/g,"+");
};
(function(){var B={"'":true,"!":true},A={array:function(D){var F=["!("],C,I,H,E=D.length,G;
for(H=0;
H<E;
H+=1){G=D[H];
I=A[typeof G];
if(I){G=I(G);
if(typeof G=="string"){if(C){F[F.length]=",";
}F[F.length]=G;
C=true;
}}}F[F.length]=")";
return F.join("");
},"boolean":function(C){if(C){return"!t";
}return"!f";
},"null":function(C){return"!n";
},number:function(C){if(!isFinite(C)){return"!n";
}return String(C).replace(/\+/,"");
},object:function(D){if(D){if(D instanceof Array){return A.array(D);
}if(typeof D.__prototype__==="object"&&typeof D.__prototype__.encode_rison!=="undefined"){return D.encode_rison();
}var E=["("],C,H,G,F,I,J=[];
for(G in D){J[J.length]=G;
}J.sort();
for(I=0;
I<J.length;
I++){G=J[I];
F=D[G];
H=A[typeof F];
if(H){F=H(F);
if(typeof F=="string"){if(C){E[E.length]=",";
}E.push(A.string(G),":",F);
C=true;
}}}E[E.length]=")";
return E.join("");
}return"!n";
},string:function(C){if(C==""){return"''";
}if(rison.id_ok.test(C)){return C;
}C=C.replace(/(['!])/g,function(E,D){if(B[D]){return"!"+D;
}return D;
});
return"'"+C+"'";
},undefined:function(C){throw new Error("rison can't encode the undefined value");
}};
rison.encode=function(C){return A[typeof C](C);
};
rison.encode_object=function(C){if(typeof C!="object"||C===null||C instanceof Array){throw new Error("rison.encode_object expects an object argument");
}var D=A[typeof C](C);
return D.substring(1,D.length-1);
};
rison.encode_array=function(C){if(!(C instanceof Array)){throw new Error("rison.encode_array expects an array argument");
}var D=A[typeof C](C);
return D.substring(2,D.length-1);
};
rison.encode_uri=function(C){return rison.quote(A[typeof C](C));
};
})();
rison.decode=function(B){var A=function(D){throw Error("rison decoder error: "+D);
};
var C=new rison.parser(A);
return C.parse(B);
};
rison.decode_object=function(A){return rison.decode("("+A+")");
};
rison.decode_array=function(A){return rison.decode("!("+A+")");
};
rison.parser=function(A){this.errorHandler=A;
};
rison.parser.WHITESPACE="";
rison.parser.prototype.setOptions=function(A){if(A["errorHandler"]){this.errorHandler=A.errorHandler;
}};
rison.parser.prototype.parse=function(B){this.string=B;
this.index=0;
this.message=null;
var A=this.readValue();
if(!this.message&&this.next()){A=this.error("unable to parse string as rison: '"+rison.encode(B)+"'");
}if(this.message&&this.errorHandler){this.errorHandler(this.message,this.index);
}return A;
};
rison.parser.prototype.error=function(A){if(typeof (console)!="undefined"){console.log("rison parser error: ",A);
}this.message=A;
return undefined;
};
rison.parser.prototype.readValue=function(){var F=this.next();
var D=F&&this.table[F];
if(D){return D.apply(this);
}var C=this.string;
var B=this.index-1;
rison.next_id.lastIndex=B;
var A=rison.next_id.exec(C);
if(A.length>0){var E=A[0];
this.index=B+E.length;
return E;
}if(F){return this.error("invalid character: '"+F+"'");
}return this.error("empty expression");
};
rison.parser.parse_array=function(D){var A=[];
var C;
while((C=D.next())!=")"){if(!C){return D.error("unmatched '!('");
}if(A.length){if(C!=","){D.error("missing ','");
}}else{if(C==","){return D.error("extra ','");
}else{--D.index;
}}var B=D.readValue();
if(typeof B=="undefined"){return undefined;
}A.push(B);
}return A;
};
rison.parser.bangs={t:true,f:false,n:null,"(":rison.parser.parse_array};
rison.parser.prototype.table={"!":function(){var B=this.string;
var C=B.charAt(this.index++);
if(!C){return this.error('"!" at end of input');
}var A=rison.parser.bangs[C];
if(typeof (A)=="function"){return A.call(null,this);
}else{if(typeof (A)=="undefined"){return this.error('unknown literal: "!'+C+'"');
}}return A;
},"(":function(){var D={};
var E;
var C=0;
while((E=this.next())!=")"){if(C){if(E!=","){this.error("missing ','");
}}else{if(E==","){return this.error("extra ','");
}else{--this.index;
}}var B=this.readValue();
if(typeof B=="undefined"){return undefined;
}if(this.next()!=":"){return this.error("missing ':'");
}var A=this.readValue();
if(typeof A=="undefined"){return undefined;
}D[B]=A;
C++;
}return D;
},"'":function(){var C=this.string;
var B=this.index;
var E=B;
var A=[];
var D;
while((D=C.charAt(B++))!="'"){if(!D){return this.error('unmatched "\'"');
}if(D=="!"){if(E<B-1){A.push(C.slice(E,B-1));
}D=C.charAt(B++);
if("!'".indexOf(D)>=0){A.push(D);
}else{return this.error('invalid string escape: "!'+D+'"');
}E=B;
}}if(E<B-1){A.push(C.slice(E,B-1));
}this.index=B;
return A.length==1?A[0]:A.join("");
},"-":function(){var B=this.string;
var A=this.index;
var G=A-1;
var C="int";
var F="-";
var D={"int+.":"frac","int+e":"exp","frac+e":"exp"};
do{var E=B.charAt(A++);
if(!E){break;
}if("0"<=E&&E<="9"){continue;
}if(F.indexOf(E)>=0){F="";
continue;
}C=D[C+"+"+E.toLowerCase()];
if(C=="exp"){F="-";
}}while(C);
this.index=--A;
B=B.slice(G,A);
if(B=="-"){return this.error("invalid number");
}return Number(B);
}};
(function(B){for(var A=0;
A<=9;
A++){B[String(A)]=B["-"];
}})(rison.parser.prototype.table);
rison.parser.prototype.next=function(){var B=this.string;
var A=this.index;
do{if(A==B.length){return undefined;
}var C=B.charAt(A++);
}while(rison.parser.WHITESPACE.indexOf(C)>=0);
this.index=A;
return C;
};


/* jquery.cookie.js */
jQuery.cookie=function(B,I,L){if(typeof I!="undefined"){L=L||{};
if(I===null){I="";
L.expires=-1;
}var E="";
if(L.expires&&(typeof L.expires=="number"||L.expires.toUTCString)){var F;
if(typeof L.expires=="number"){F=new Date();
F.setTime(F.getTime()+(L.expires*24*60*60*1000));
}else{F=L.expires;
}E="; expires="+F.toUTCString();
}var K=L.path?"; path="+(L.path):"";
var G=L.domain?"; domain="+(L.domain):"";
var A=L.secure?"; secure":"";
document.cookie=[B,"=",encodeURIComponent(I),E,K,G,A].join("");
}else{var D=null;
if(document.cookie&&document.cookie!=""){var J=document.cookie.split(";");
for(var H=0;
H<J.length;
H++){var C=jQuery.trim(J[H]);
if(C.substring(0,B.length+1)==(B+"=")){D=decodeURIComponent(C.substring(B.length+1));
break;
}}}return D;
}};


/* jsonp-queue.js */
(function(){var A=window.MetawebSuite;
A.core.JsonpQueue=function(){this._pendingCallIDs={};
this._callInProgress=0;
};
A.core.JsonpQueue.prototype.cancelAll=function(){this._pendingCallIDs={};
};
A.core.JsonpQueue.prototype.call=function(B,E,G,C){if(this._callInProgress==0){document.body.style.cursor="progress";
}this._callInProgress++;
var F=new Date().getTime()+"x"+Math.floor(Math.random()*1000);
var I=document.createElement("script");
I.setAttribute("onerror","err"+F+"();");
B+=(B.indexOf("?")<0?"?":"&")+"callback=cb"+F;
I.setAttribute("src",B);
var K=this;
var D=function(){K._callInProgress--;
if(K._callInProgress==0){document.body.style.cursor="auto";
}if(!(C)){I.parentNode.removeChild(I);
}try{delete window["cb"+F];
delete window["err"+F];
}catch(L){window["cb"+F]=undefined;
window["err"+F]=undefined;
}if(F in K._pendingCallIDs){delete K._pendingCallIDs[F];
return true;
}else{return false;
}};
var J=function(M){if(D()){try{E(M);
}catch(L){A.system.exception(L);
}}};
var H=function(){if(D()){if(typeof G=="function"){try{G(B);
}catch(L){A.system.exception(L);
}}}};
window["cb"+F]=J;
window["err"+F]=H;
this._pendingCallIDs[F]=true;
document.getElementsByTagName("head")[0].appendChild(I);
};
})();


/* listener-queue.js */
(function(){var A=window.MetawebSuite;
A.core.ListenerQueue=function(B){this._listeners=[];
this._wildcardHandlerName=B;
};
A.core.ListenerQueue.prototype={add:function(B){this._listeners.push(B);
},remove:function(D){var C=this._listeners;
for(var B=0;
B<C.length;
B++){if(C[B]==D){C.splice(B,1);
break;
}}},fire:function(C,B){var E=[].concat(this._listeners);
for(var D=0;
D<E.length;
D++){var F=E[D];
if(C in F){try{F[C].apply(F,B);
}catch(G){A.system.exception(G,"Error firing event of name "+C);
}}else{if(this._wildcardHandlerName!=null&&this._wildcardHandlerName in F){try{F[this._wildcardHandlerName].apply(F,[C]);
}catch(G){A.system.exception(G,"Error firing event of name "+C+" to wildcard handler");
}}}}}};
})();


/* misc.js */
window.myJQuery=window.jQuery;
(function(){var A=function(E){if(E instanceof Array){var B=[];
for(var C=0;
C<E.length;
C++){B.push(A(E[C]));
}return B;
}else{if(typeof E=="object"){var D={};
for(var F in E){if(E.hasOwnProperty(F)){D[F]=A(E[F]);
}}return D;
}else{return E;
}}};
mw.system.clone=A;
})();


/* string.js */
(function(){String.startsWith=function(B,A){return B!=null&&B.length>=A.length&&B.substr(0,A.length)==A;
};
String.endsWith=function(B,A){return B!=null&&B.length>=A.length&&B.substr(B.length-A.length)==A;
};
String.trim=function(A){return A.replace(/^\s+/,"").replace(/\s+$/,"");
};
String.padNumber=function(A){if(A<10){return"00"+A;
}else{if(A<100){return"0"+A;
}else{return A;
}}};
String.formatNumberWithSeparators=function(B){if(B<1){return B;
}else{var A=[];
while(B>1000){A.unshift(padNumber(B%1000));
B=Math.floor(B/1000);
}A.unshift(B);
return A.join(",");
}};
String.formatNumberWithSuffix=function(A){if(A>1000000000){return(Math.floor(A/100000000)/10)+"B";
}else{if(A>1000000){return(Math.floor(A/100000)/10)+"M";
}else{if(A>1000){return(Math.floor(A/100)/10)+"K";
}else{if(A>1){return A;
}else{if(A>0.001){return(Math.floor(A/0.0001)/10)+"m";
}else{if(A>0.000001){return(Math.floor(A/1e-7)/10)+"u";
}else{return A;
}}}}}}};
})();


/* terminal.js */
window.MetawebSuite.system.onFinishLoadingPackage("metaweb-suite-core");


/* ui-package.js */
(function() {
    mw.system.onStartLoadingNativePackage(
        "ui",
        [   "ui.js",
            "history.js",
            "layers.js",
            "dnd.js",
            "animation.js",
            "menus.js",
            "color-coder.js",
            "ui-context.js",
            "terminal.js"
        ],
        [   "ui.css"
        ]
    );
})();


/* ui-bundle.js */


/* animation.js */
(function(){var A=window.MetawebSuite;
A.ui.Animation=function(C,F,E,D,B){this.f=C;
this.cont=(typeof B=="function")?B:function(){};
this.from=F;
this.to=E;
this.current=F;
this.duration=D;
this.start=new Date().getTime();
this.timePassed=0;
};
A.ui.Animation.prototype.run=function(){var B=this;
window.setTimeout(function(){B.step();
},50);
};
A.ui.Animation.prototype.step=function(){this.timePassed+=50;
var C=this.timePassed/this.duration;
var B=-Math.cos(C*Math.PI)/2+0.5;
var E=B*(this.to-this.from)+this.from;
try{this.f(E,E-this.current);
}catch(D){}this.current=E;
if(this.timePassed<this.duration){this.run();
}else{this.f(this.to,0);
this["cont"]();
}};
})();


/* color-coder.js */
function DefaultColorCoder(){this._colorMap={};
this._colorMax=0;
}DefaultColorCoder.defaultColors=["#FF9000","#5D7CBA","#A97838","#8B9BBA","#FFC77F","#003EBA","#29447B","#543C1C"];
DefaultColorCoder.prototype.getColorForKey=function(B){if(B in this._colorMap){return this._colorMap[B];
}else{var A=this._colorMap[B]=DefaultColorCoder.defaultColors[this._colorMax];
this._colorMax=(this._colorMax+1)%DefaultColorCoder.defaultColors.length;
return A;
}};
DefaultColorCoder.prototype.getDefaultColor=function(){return"#FF9000";
};


/* dnd.js */
(function(){var B=window.MetawebSuite;
var A=B.ui.dnd={_initialized:false,_draggedElement:null,_draggedElementCallback:null,_dropTargetHighlightElement:null,_lastCoords:null,_ghostCoords:null,_draggingMode:"",_dragging:false};
A.initialize=function(){if(A._initialized){return ;
}myJQuery(document.body).bind("mousedown",A._onBodyMouseDown).bind("mousemove",A._onBodyMouseMove).bind("mouseup",A._onBodyMouseUp).bind("keydown",A._onBodyKeyDown).bind("keyup",A._onBodyKeyUp);
A._initialized=true;
};
A.makeDraggable=function(D,F,C){A.initialize();
var E=function(G){return A._handleMouseDown(this,G,F);
};
myJQuery(D).mousedown(E);
return{dispose:function(){myJQuery(D).unbind("mousedown",E);
}};
};
A._handleMouseDown=function(D,C,E){A._draggedElement=D;
A._draggedElementCallback=E;
A._lastCoords={x:C.clientX,y:C.clientY};
return B.ui.cancelEvent(C);
};
A._onBodyMouseDown=function(C){if(!("eventPhase" in C)||C.eventPhase==C.BUBBLING_PHASE){B.ui.layers.cancelPopups(C);
}};
A._onBodyKeyDown=function(C){if(A._dragging){if(C.keyCode==27){A._cancelDragging();
}else{if((C.keyCode==17||C.keyCode==16)&&A._draggingMode!="copy"){A._draggingMode="copy";
var D=B.ui.createTranslucentImage(B.ui.params.urlPrefix+"images/copy.png");
D.style.position="absolute";
D.style.left=(A._ghostCoords.left-16)+"px";
D.style.top=(A._ghostCoords.top)+"px";
document.body.appendChild(D);
A._draggingModeIndicatorElmt=D;
}}}};
A._onBodyKeyUp=function(C){if(A._dragging){if(C.keyCode==17||C.keyCode==16){A._draggingMode="";
if(A._draggingModeIndicatorElmt!=null){document.body.removeChild(A._draggingModeIndicatorElmt);
A._draggingModeIndicatorElmt=null;
}}}};
A._onBodyMouseMove=function(O){if(A._draggedElement!=null){var P=A._draggedElementCallback;
var F=A._lastCoords;
var N=O.clientX-F.x;
var K=O.clientY-F.y;
if(!A._dragging){if(Math.abs(N)>5||Math.abs(K)>5){try{if("onDragStart" in P){P.onDragStart();
}if("ghost" in P&&P.ghost){var L=A._draggedElement;
A._ghostCoords=SimileAjax.DOM.getPageCoordinates(L);
A._ghostCoords.left+=N;
A._ghostCoords.top+=K;
var Q=L.cloneNode(true);
Q.style.position="absolute";
Q.style.left=A._ghostCoords.left+"px";
Q.style.top=A._ghostCoords.top+"px";
Q.style.zIndex=1000;
SimileAjax.Graphics.setOpacity(Q,50);
document.body.appendChild(Q);
P._ghostElmt=Q;
}A._dragging=true;
A._lastCoords={x:O.clientX,y:O.clientY};
document.body.focus();
}catch(I){B.system.exception(I,"mw.ui.dnd: Error handling mouse down");
A._cancelDragging();
}}}else{try{A._lastCoords={x:O.clientX,y:O.clientY};
if("onDragBy" in P){P.onDragBy(N,K);
}if("_ghostElmt" in P){var Q=P._ghostElmt;
A._ghostCoords.left+=N;
A._ghostCoords.top+=K;
Q.style.left=A._ghostCoords.left+"px";
Q.style.top=A._ghostCoords.top+"px";
if(A._draggingModeIndicatorElmt!=null){var J=A._draggingModeIndicatorElmt;
J.style.left=(A._ghostCoords.left-16)+"px";
J.style.top=A._ghostCoords.top+"px";
}if("droppable" in P&&P.droppable){var M=B.ui.getEventPageCoordinates(O);
var H=B.ui.hittest(M.x,M.y,[A._ghostElmt,A._dropTargetHighlightElement]);
H=A._findDropTarget(H);
if(H!=A._potentialDropTarget){if(A._dropTargetHighlightElement!=null){document.body.removeChild(A._dropTargetHighlightElement);
A._dropTargetHighlightElement=null;
A._potentialDropTarget=null;
}var G=false;
if(H!=null){if((!("canDropOn" in P)||P.canDropOn(H))&&(!("canDrop" in H)||H.canDrop(A._draggedElement))){G=true;
}}if(G){var D=4;
var E=B.ui.getPageCoordinates(H);
var C=B.ui.createHTMLElement("div");
C.style.border=D+"px solid yellow";
C.style.backgroundColor="yellow";
C.style.position="absolute";
C.style.left=E.left+"px";
C.style.top=E.top+"px";
C.style.width=(H.offsetWidth-D*2)+"px";
C.style.height=(H.offsetHeight-D*2)+"px";
B.ui.setOpacity(C,30);
document.body.appendChild(C);
A._potentialDropTarget=H;
A._dropTargetHighlightElement=C;
}}}}}catch(I){B.system.exception("WindowManager: Error handling mouse move",I);
A._cancelDragging();
}}return B.ui.cancelEvent(O);
}};
A._onBodyMouseUp=function(C){if(A._draggedElement!=null){try{if(A._dragging){var F=A._draggedElementCallback;
if("onDragEnd" in F){F.onDragEnd();
}if("droppable" in F&&F.droppable){var E=false;
var D=A._potentialDropTarget;
if(D!=null){if((!("canDropOn" in F)||F.canDropOn(D))&&(!("canDrop" in D)||D.canDrop(A._draggedElement))){if("onDropOn" in F){F.onDropOn(D);
}D.ondrop(A._draggedElement,A._draggingMode);
E=true;
}}if(!E){}}}}finally{A._cancelDragging();
}return B.ui.cancelEvent(C);
}};
A._cancelDragging=function(){var D=A._draggedElementCallback;
if("_ghostElmt" in D){var C=D._ghostElmt;
document.body.removeChild(C);
delete D._ghostElmt;
}if(A._dropTargetHighlightElement!=null){document.body.removeChild(A._dropTargetHighlightElement);
A._dropTargetHighlightElement=null;
}if(A._draggingModeIndicatorElmt!=null){document.body.removeChild(A._draggingModeIndicatorElmt);
A._draggingModeIndicatorElmt=null;
}A._draggedElement=null;
A._draggedElementCallback=null;
A._potentialDropTarget=null;
A._dropTargetHighlightElement=null;
A._lastCoords=null;
A._ghostCoords=null;
A._draggingMode="";
A._dragging=false;
};
A._findDropTarget=function(C){while(C!=null){if("ondrop" in C&&(typeof C.ondrop)=="function"){break;
}C=C.parentNode;
}return C;
};
})();


/* history.js */
(function(){var B=window.MetawebSuite;
var A=B.ui.history={maxHistoryLength:10,historyFile:"__history__.html",enabled:true,_initialized:false,_actions:[],_baseIndex:0,_currentIndex:0};
A.formatHistoryEntryTitle=function(C){return A._plainDocumentTitle+" {"+C+"}";
};
A.initialize=function(){if(A._initialized){return ;
}A._listeners=new B.core.ListenerQueue();
if(A.enabled){A._plainDocumentTitle=document.title;
var C=B.ui.createHTMLElement("iframe");
C.id="simile-ajax-history";
C.style.position="absolute";
C.style.width="10px";
C.style.height="10px";
C.style.top="0px";
C.style.left="0px";
C.style.visibility="hidden";
C.src=A.historyFile+"?0";
document.body.appendChild(C);
myJQuery(C).bind("load",A._handleIFrameOnLoad);
A._iframe=C;
}A._initialized=true;
};
A.addListener=function(C){A.initialize();
A._listeners.add(C);
};
A.removeListener=function(C){A.initialize();
A._listeners.remove(C);
};
A.addAction=function(C){A.initialize();
A._listeners.fire("onBeforePerform",[C]);
window.setTimeout(function(){try{C.perform();
A._listeners.fire("onAfterPerform",[C]);
if(A.enabled){A._actions=A._actions.slice(0,A._currentIndex-A._baseIndex);
A._actions.push(C);
A._currentIndex++;
var E=A._actions.length-A.maxHistoryLength;
if(E>0){A._actions=A._actions.slice(E);
A._baseIndex+=E;
}try{A._iframe.contentWindow.location.href=A.historyFile+"?"+A._currentIndex;
}catch(D){var F=A.formatHistoryEntryTitle(C.label);
document.title=F;
}}}catch(D){B.system.exception(D,"Error adding action {"+C.label+"} to history");
}},0);
};
A.addLengthyAction=function(E,C,D){A.addAction({perform:E,undo:C,label:D,uiLayer:B.ui.layers.getBaseLayer(),lengthy:true});
};
A._handleIFrameOnLoad=function(){try{var C=A._iframe.contentWindow.location.href;
var E=C.indexOf("?");
var I=(E<0)?0:Math.max(0,parseInt(C.substr(E+1)));
var H=function(){var J=I-A._currentIndex;
A._currentIndex+=J;
A._baseIndex+=J;
A._iframe.contentWindow.location.search="?"+I;
};
if(I<A._currentIndex){A._listeners.fire("onBeforeUndoSeveral",[]);
window.setTimeout(function(){while(A._currentIndex>I&&A._currentIndex>A._baseIndex){A._currentIndex--;
var J=A._actions[A._currentIndex-A._baseIndex];
try{J.undo();
}catch(K){B.core.exception(K,"History: Failed to undo action {"+J.label+"}");
}}A._listeners.fire("onAfterUndoSeveral",[]);
H();
},0);
}else{if(I>A._currentIndex){A._listeners.fire("onBeforeRedoSeveral",[]);
window.setTimeout(function(){while(A._currentIndex<I&&A._currentIndex-A._baseIndex<A._actions.length){var J=A._actions[A._currentIndex-A._baseIndex];
try{J.perform();
}catch(K){B.core.exception(K,"History: Failed to redo action {"+J.label+"}");
}A._currentIndex++;
}A._listeners.fire("onAfterRedoSeveral",[]);
H();
},0);
}else{var D=A._currentIndex-A._baseIndex-1;
var G=(D>=0&&D<A._actions.length)?A.formatHistoryEntryTitle(A._actions[D].label):A._plainDocumentTitle;
A._iframe.contentWindow.document.title=G;
document.title=G;
}}}catch(F){}};
A.getNextUndoAction=function(){try{var C=A._currentIndex-A._baseIndex-1;
return A._actions[C];
}catch(D){return null;
}};
A.getNextRedoAction=function(){try{var C=A._currentIndex-A._baseIndex;
return A._actions[C];
}catch(D){return null;
}};
})();


/* layers.js */
(function(){var B=window.MetawebSuite;
var A=B.ui.layers={_initialized:false,_layers:[]};
A.initialize=function(){if(A._initialized){return ;
}A._layers.push({index:0});
myJQuery(window).mousedown(function(C){A.cancelPopups(C);
});
myJQuery(window).keyup(function(C){if(C.keyCode==27){A.cancelTopMostPopup();
}});
A._initialized=true;
};
A.getBaseLayer=function(){A.initialize();
return A._layers[0];
};
A.getHighestLayer=function(){A.initialize();
return A._layers[A._layers.length-1];
};
A.tryAccessLayer=function(C){A.initialize();
if(A._canProcessEventAtLayer(C)){A._popToLayer(C.index);
return true;
}return false;
};
A.pushLayer=function(C,D){A.initialize();
return A._pushLayer(C,D,false);
};
A.pushEphemeralLayer=function(C,D){A.initialize();
return A._pushLayer(C,D,true);
};
A._pushLayer=function(D,E,F){var C={index:A._layers.length,onPop:D,ephemeral:F,elmts:E||[]};
A._layers.push(C);
return C;
};
A.popLayer=function(C){A.initialize();
A._popToLayer(C.index-1);
};
A.popAllLayers=function(){A.initialize();
A._popToLayer(0);
};
A._popToLayer=function(E){while(E+1<A._layers.length){try{var C=A._layers.pop();
if(C.onPop!=null){C.onPop();
}}catch(D){B.system.exception(D);
}}};
A._canProcessEventAtLayer=function(D){if(D.index==(A._layers.length-1)){return true;
}for(var C=D.index+1;
C<A._layers.length;
C++){if(!A._layers[C].ephemeral){return false;
}}return true;
};
A.cancelPopups=function(K){A.initialize();
var E=(K)?B.ui.getEventPageCoordinates(K):{x:-1,y:-1};
var H=A._layers.length-1;
while(H>0&&A._layers[H].ephemeral){var I=A._layers[H];
if(I.elmts!=null){var F=I.elmts;
var C=false;
for(var G=0;
G<F.length;
G++){var D=F[G];
var J=B.ui.getPageCoordinates(D);
if(E.x>=J.left&&E.x<(J.left+D.offsetWidth)&&E.y>=J.top&&E.y<(J.top+D.offsetHeight)){C=true;
break;
}}if(C){break;
}}H--;
}A._popToLayer(H);
};
A.cancelTopMostPopup=function(){if(A._layers.length>1){if(A._layers[A._layers.length-1].ephemeral){A._popToLayer(A._layers.length-2);
}}};
})();


/* menus.js */
(function(){var C=window.MetawebSuite;
var B=C.ui.menus={};
var A=B.PopupMenu=function(E){var G=C.ui.createHTMLElement("div");
G.className="menu-popup";
var F=C.ui.createHTMLElement("div");
F.className="menu-popup-body";
G.appendChild(F);
var D=this;
this.elmt=G;
this.bodyDiv=F;
this.close=function(){C.ui.removeFromDom(G);
};
this.open=function(){C.ui.addToDom(G);
var I=document.body.offsetWidth;
var H=document.body.offsetHeight;
var J=C.ui.getPageCoordinates(E);
G.style.top=(J.top+E.scrollHeight)+"px";
G.style.right=(I-(J.left+E.scrollWidth))+"px";
D.layer=C.ui.layers.pushEphemeralLayer(function(){D.close();
},[G]);
};
this.appendMenuItem=function(I,J,K){var H=C.ui.createHTMLElement("a");
H.className="menu-item";
H.href="javascript:";
myJQuery(H).click(function(M){if(C.ui.layers.tryAccessLayer(D.layer)){K(this,M);
}C.ui.layers.popLayer(D.layer);
return C.ui.cancelEvent(M);
});
var L=C.ui.createHTMLElement("div");
H.appendChild(L);
L.appendChild(C.ui.createTranslucentImage(J!=null?J:(C.ui.params.baseUrl+"images/blank-16x16.png")));
if(typeof I=="string"){L.appendChild(document.createTextNode(I));
}else{L.appendChild(I);
}F.appendChild(H);
return H;
};
this.appendSection=function(H){var I=C.ui.createHTMLElement("div");
I.className="menu-section";
I.appendChild(document.createTextNode(H));
F.appendChild(I);
return I;
};
this.appendSeparator=function(){var H=C.ui.createHTMLElement("hr");
F.appendChild(H);
};
};
})();


/* ui-context.js */
(function(){var B=window.MetawebSuite;
var A=B.ui.UIContext=function(C){this._parent=C?C:null;
this._settings={};
};
A.prototype.dispose=function(){};
A.prototype.getParentUIContext=function(){return this._parent;
};
A.prototype.getSetting=function(C){return C in this._settings?this._settings[C]:(this._parent!=null?this._parent.getSetting(C):undefined);
};
A.prototype.getBooleanSetting=function(E,C){var D=this.getSetting(E);
return D==undefined||D==null?C:D;
};
A.prototype.putSetting=function(C,D){this._settings[C]=D;
};
})();


/* ui.js */
(function(){var D=window.MetawebSuite;
D.ui.addToDom=function(E){document.body.appendChild(E);
};
D.ui.removeFromDom=function(E){E.parentNode.removeChild(E);
};
D.ui.createHTMLElement=document.contentType=="application/vnd.mozilla.xul+xml"?function(E){return document.createElementNS("http://www.w3.org/1999/xhtml",E);
}:function(E){return document.createElement(E);
};
D.ui.cancelEvent=function(E){E.returnValue=false;
E.cancelBubble=true;
if("preventDefault" in E){E.preventDefault();
}return false;
};
D.ui.getPageCoordinates=function(F){var I=0;
var H=0;
if(F.nodeType!=1){F=F.parentNode;
}var G=F;
while(G!=null){I+=G.offsetLeft;
H+=G.offsetTop;
G=G.offsetParent;
}var E=document.body;
while(F!=null&&F!=E){if("scrollLeft" in F){I-=F.scrollLeft;
H-=F.scrollTop;
}F=F.parentNode;
}return{left:I,top:H};
};
D.ui.getEventRelativeCoordinates=function(E,F){if(myJQuery.browser.msie){return{x:E.offsetX,y:E.offsetY};
}else{var G=D.ui.getPageCoordinates(F);
return{x:E.pageX-G.left,y:E.pageY-G.top};
}};
D.ui.getEventPageCoordinates=function(E){if(myJQuery.browser.msie){return{x:E.clientX+document.body.scrollLeft,y:E.clientY+document.body.scrollTop};
}else{return{x:E.pageX,y:E.pageY};
}};
D.ui.pngIsTranslucent=(!myJQuery.browser.msie)||(parseFloat(myJQuery.browser.version.substr(0,2))>6);
var B=function(E,G){var F=D.ui.createHTMLElement("img");
F.setAttribute("src",E);
if(G!=null){F.style.verticalAlign=G;
}return F;
};
var A=function(E,G){var F=D.ui.createHTMLElement("img");
F.style.width="1px";
F.style.height="1px";
F.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+E+"', sizingMethod='image')";
F.style.verticalAlign=(G!=null)?G:"middle";
return F;
};
D.ui.createTranslucentImage=D.ui.pngIsTranslucent?B:A;
D.ui.setOpacity=function(F,E){if(D.ui.pngIsTranslucent){var G=(E/100).toString();
F.style.opacity=G;
F.style.MozOpacity=G;
}else{F.style.filter="progid:DXImageTransform.Microsoft.Alpha(Style=0,Opacity="+E+")";
}};
var C=function(G,P,O,L){var Q=G.childNodes;
outer:for(var K=0;
K<Q.length;
K++){var E=Q[K];
for(var J=0;
J<L.length;
J++){if(E==L[J]){continue outer;
}}if(E.offsetWidth==0&&E.offsetHeight==0){var F=C(E,P,O,L);
if(F!=E){return F;
}}else{var N=0;
var I=0;
var H=E;
while(H){N+=H.offsetTop;
I+=H.offsetLeft;
H=H.offsetParent;
}if(I<=P&&N<=O&&(P-I)<E.offsetWidth&&(O-N)<E.offsetHeight){return C(E,P,O,L);
}else{if(E.nodeType==1&&E.tagName=="TR"){var M=C(E,P,O,L);
if(M!=E){return M;
}}}}}return G;
};
D.ui.hittest=function(E,G,F){return C(document.body,E,G,F);
};
D.ui.showLightboxForImage=function(J,G){var L=D.ui.createHTMLElement("div");
L.style.position="fixed";
L.style.top="0px";
L.style.left="0px";
L.style.width="100%";
L.style.height="100%";
L.style.background="black";
L.style.opacity=0.5;
L.style.zIndex=1000;
D.ui.addToDom(L);
var F=D.ui.createHTMLElement("div");
F.style.position="fixed";
F.style.top="0px";
F.style.left="0px";
F.style.width="100%";
F.style.height="100%";
F.style.zIndex=1001;
F.style.textAlign="center";
D.ui.addToDom(F);
var E=F.offsetHeight;
var I=Math.max(1,Math.floor(E/100)-1)*100;
var H=(typeof J=="string")?J:J.src;
var K=H.indexOf("?");
H=H.substr(0,K)+"?mode=fill&maxheight="+I;
F.innerHTML='<img src="'+H+'" style="margin-top: 50px; padding: 10px; border: 1px solid #aaa;" />';
F.onclick=function(){D.ui.removeFromDom(F);
D.ui.removeFromDom(L);
};
if(G){return D.ui.cancelEvent(G);
}};
})();


/* terminal.js */
window.MetawebSuite.system.onFinishLoadingPackage("metaweb-suite-ui");


/* freebase-package.js */
(function() {
    mw.system.onStartLoadingNativePackage(
        "freebase",
        [   "init.js",
            "mql.js",
            "schemas.js",
            "path.js",
            "dimension.js",
            "type-stack.js",
            "mpl/parser.js",
            "mpl/controls.js",
            "mpl/functions.js",
            "mpl/evaluator.js",
            "terminal.js"
        ],
        [
        ]
    );
})();


/* freebase-bundle.js */


/* init.js */
(function(){if("freebase-location" in mw.freebase.params){mw.freebase.location=mw.freebase.params["freebase-location"];
}else{if("freebase-location" in mw.system.urlParams){mw.freebase.location=mw.system.urlParams["freebase-location"];
}}if("location" in mw.freebase){var A=mw.freebase.location;
if(A=="sandbox"){mw.freebase.location="http://sandbox.freebase.com/";
}else{if(A.indexOf("://")<0){A="http://"+A;
}if(!String.endsWith(A,"/")){A=A+"/";
}mw.freebase.location=A;
}}else{mw.freebase.location="http://www.freebase.com/";
}mw.freebase.apiLocation=mw.freebase.location+"api/";
mw.freebase.serviceLocation=mw.freebase.apiLocation+"service/";
if(mw.freebase.location.indexOf("http://sandbox.")==0){mw.freebase.appsDomain="sandbox-freebaseapps.com";
}else{mw.freebase.appsDomain="freebaseapps.com";
}})();


/* dimension.js */
(function(){var C=window.MetawebSuite;
var B=C.freebase.Dimension=function(D){B._checkPath(D);
this._propertyPath=D.clone();
};
B.parseString=function(D){return new B(PropertyPath.parseString(D));
};
B._checkPath=function(D){var E=D.getSegmentCount();
if(E>2){throw new Error("Dimension's property path must have no more than two segments: "+D.toString());
}};
B.prototype.getSegmentCount=function(){return this._propertyPath.getSegmentCount();
};
B.prototype.getLastSegment=function(){return this._propertyPath.getLastSegment();
};
B.prototype.getLastPropertyID=function(){return this._propertyPath.getLastPropertyID();
};
B.prototype.toString=function(){return this._propertyPath.toString();
};
B.prototype.getPath=function(){return this._propertyPath.clone();
};
var A=C.freebase.DimensionPath=function(){this._dimensions=[];
};
A.prototype.getTotalPropertyPath=function(){};
})();


/* mql.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.mql={getJsonpQueue:function(){if(!("jsonpQueue" in A)){A.jsonpQueue=new B.core.JsonpQueue();
}return A.jsonpQueue;
},getMqlReadUrl:function(){if(!("mqlreadUrl" in A)){A.mqlreadUrl=B.freebase.serviceLocation+"mqlread";
}return A.mqlreadUrl;
},cancelAllQueries:function(){A.getJsonpQueue().cancelAll();
},error:function(C,D){B.system.log(C);
}};
A.readThroughQueue=function(I,J,F,G,E){var C=JSON.stringify({"q1":{"query":J}});
var D=A.getMqlReadUrl()+"?queries="+encodeURIComponent(C);
var K=function(L){if(L.q1.code=="/api/status/error"){if(typeof G=="function"){G(L.q1.messages[0].message,J);
}}else{F(L.q1);
}};
var H=function(){if(typeof G=="function"){G("Unknown",J);
}};
I.call(D,K,H,E);
};
A.read=function(E,F,D,C){A.readThroughQueue(A.getJsonpQueue(),E,F,D,C);
};
A.makeQueryNodeOptionalIfEmpty=function(C){var D=false;
for(var E in C){if(C.hasOwnProperty(E)){D=true;
break;
}}if(!D){C["optional"]=true;
}};
})();


/* path.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.PropertyPath=function(){this._segments=[];
};
A.createForwardPath=function(E){var C=new A();
for(var D=0;
D<E.length;
D++){C.appendSegment(E[D],true);
}return C;
};
A.parseString=function(K){var D=new A();
var E=0;
while(E<K.length-1){var F=K.charAt(E);
var G;
if(F=="."){G=true;
}else{if(F=="!"){G=false;
}else{throw new Error("Invalid property path string: "+K);
}}var C=K.indexOf(".",E+1);
var I=K.indexOf("!",E+1);
var H;
if(C>=0){if(I>=0&&I<C){H=I;
}else{H=C;
}}else{if(I>=0){H=I;
}else{H=K.length;
}}var J=K.substring(E+1,H);
D.appendSegment(J,G);
E=H;
}return D;
};
A.prototype.clone=function(){var C=new A();
for(var D=0;
D<this._segments.length;
D++){var E=this._segments[D];
C._segments.push({propertyID:E.propertyID,forward:E.forward});
}return C;
};
A.prototype.forEachSegment=function(D){for(var C=0;
C<this._segments.length;
C++){D(this._segments[C],C);
}};
A.prototype.forEachSegmentBackward=function(D){for(var C=this._segments.length-1;
C>=0;
C--){D(this._segments[C],C);
}};
A.prototype.getSegmentCount=function(){return this._segments.length;
};
A.prototype.getSegment=function(C){var D=this._internalGetSegment(C);
if(D!=null){return{propertyID:D.propertyID,forward:D.forward};
}else{return null;
}};
A.prototype._internalGetSegment=function(C){return(C>=0&&C<this._segments.length)?this._segments[C]:null;
};
A.prototype.getLastSegment=function(){return this.getSegment(this._segments.length-1);
};
A.prototype.getLastPropertyID=function(){var C=this._internalGetSegment(this._segments.length-1);
return C!=null?C.propertyID:null;
};
A.prototype.appendSegment=function(D,C){this._segments.push({propertyID:D,forward:C});
};
A.prototype.toString=function(){var C=[];
for(var D=0;
D<this._segments.length;
D++){var E=this._segments[D];
C.push(E.forward?".":"!");
C.push(E.propertyID);
}return C.join("");
};
A.segmentToForwardMqlKey=function(C){return(C.forward)?C.propertyID:("!"+C.propertyID);
};
A.segmentToBackwardMqlKey=function(C){return(!C.forward)?C.propertyID:("!"+C.propertyID);
};
A.pathToJSON=function(G){var F=[];
for(var C=0;
C<G._segments.length;
C++){var E=G._segments[C];
var D={p:E.propertyID};
if(E.forward){D.f=1;
}F.push(D);
}return F;
};
A.jsonToPath=function(D){var F=new A();
for(var C=0;
C<D.length;
C++){var E=D[C];
F.appendSegment(E.p,"f" in E&&E.f==1);
}return F;
};
A.createForwardPathIterator=function(F){var C=[];
for(var D=0;
D<F._segments.length;
D++){var E=F._segments[D];
C.push(A.segmentToForwardMqlKey(E));
}var G=function(J,K,M){if(K<C.length){var I=C[K];
if(I in J){var H=J[I];
for(var L=0;
L<H.length;
L++){G(H[L],K+1,M);
}}}else{M(J);
}};
return function(H,I){G(H,0,I);
};
};
A.extendQueryNodeWithPath=function(D,I,E){if(E==undefined){E=true;
}for(var F=0;
F<I._segments.length;
F++){var G=I._segments[F];
var C=A.segmentToForwardMqlKey(G);
var H;
if(C in D){H=D[C][0];
if("return" in H){delete H["return"];
}}else{H={};
if(E){H["optional"]=true;
}D[C]=[H];
}D=H;
}return D;
};
A.extractProxyPath=function(L){var J=new A();
var F=0;
while(true){var D=true;
for(var C=0;
C<L.length;
C++){if(F>=L[C].getSegmentCount()){D=false;
break;
}}if(!D){break;
}var H=L[0].getSegment(F);
var K=H.propertyID;
var G=H.forward;
var I=true;
for(var C=1;
C<L.length;
C++){var E=L[C].getSegment(F);
if(E.propertyID!=K||H.forward!=G){I=false;
break;
}}if(I){J.appendSegment(K,G);
}else{break;
}F++;
}return J;
};
A.removeProxyPath=function(H,E){var G=new A();
var D=0;
for(;
D<H.getSegmentCount()&&D<E.getSegmentCount();
D++){var F=H.getSegment(D);
var C=E.getSegment(D);
if(F.propertyID==C.propertyID&&F.forward==C.forward){G.appendSegment(F.propertyID,F.forward);
}else{break;
}}return G;
};
})();


/* schemas.js */
(function(){var G=window.MetawebSuite;
var C=G.freebase.schemas={_typeRecords:{},_propertyRecords:{}};
var F={"/type/int":true,"/type/float":true,"/type/boolean":true,"/type/rawstring":true,"/type/uri":true,"/type/datetime":true,"/type/bytestring":true,"/type/key":true,"/type/value":true,"/type/text":true,"/type/enumeration":true};
C.isNativeType=function(H){return H in F;
};
C.getPropertyRecord=function(H){return C._propertyRecords[H];
};
C.hasPropertyRecord=function(H){return H in C._propertyRecords;
};
C.getTypeRecord=function(H){return C._typeRecords[H];
};
C.hasTypeRecord=function(H){return H in C._typeRecords;
};
C.getContainingTypeOfProperty=function(I){var H=C.getContainingTypeIDOfProperty(I);
if(H!=null&&H in C._typeRecords){return C._typeRecords[H];
}return null;
};
C.getContainingTypeIDOfProperty=function(I){var H=I.lastIndexOf("/");
if(H>0){return I.substr(0,H);
}return null;
};
C.projectTopicsToTypes=function(H,J,I){H["return"]="estimate-count";
G.freebase.mql.read([{"id":null,"type":"/type/type","/type/type/instance":[H]}],function(N){var M=[];
for(var K=0;
K<N.result.length;
K++){var L=N.result[K];
if(typeof L=="object"){M.push({id:L.id,count:("/type/type/instance" in L&&L["/type/type/instance"].length>0)?L["/type/type/instance"][0]:0});
}}J(M);
},I);
};
C.projectTopicsToTypesPreloadSchemas=function(H,J,I){C.projectTopicsToTypes(H,function(O){var N=[];
for(var M=0;
M<O.length;
M++){var L=O[M].id;
if(!(L in C._typeRecords)){N.push(L);
}}var K=function(){J(O);
};
if(N.length>0){C.getTypeSchemas(N,K,I);
}else{K();
}},I);
};
C.getTypeSchemas=function(J,L,H){var K=0;
var I=function(){if(K<J.length){var N=Math.min(K+10,J.length);
var M=J.slice(K,N);
K=N;
E(M,I,H);
}else{L();
}};
I();
};
C.getPropertySchemas=function(K,J){var I=0;
var H=function(){if(I<K.length){var M=Math.min(I+10,K.length);
var L=K.slice(I,M);
I=M;
B(L,H);
}else{J();
}};
H();
};
var E=function(I,J,H){G.freebase.mql.read([{"id|=":I,"id":null,"name":null,"/type/type/properties":[{"id":null,"name":null,"master_property":null,"unique":null,"expected_type":[{"id":null,"name":null,"/freebase/type_hints/mediator":null}]}]}],function(Q){var P={};
var K=Q.result;
for(var N=0;
N<K.length;
N++){var O=K[N];
var L={id:O.id,name:O.name,properties:[],pivotSuggestions:[],filterSuggestions:[]};
C._typeRecords[O.id]=L;
var M=O["/type/type/properties"];
D(M,L,P);
}A(P,J,H);
},H);
};
var B=function(K,J,H){var I=[{"id":K,"name":null,"expected_type":[{"id":null,"name":null,"/freebase/type_hints/mediator":null}],"master_property":null,"unique":null}];
G.freebase.mql.read(I,function(M){var L={};
D(M.result,{},L);
A(L,J,H);
},H);
};
var D=function(L,I,M){for(var J=0;
J<L.length;
J++){var H=L[J];
var N={id:H.id,name:H.name,cvt:false,expectedType:null,expectedTypeLabel:null,masterProperty:H.master_property,unique:false};
C._propertyRecords[H.id]=N;
I.properties.push(H.id);
if("unique" in H){N.unique=H.unique;
}if("expected_type" in H&&H.expected_type.length>0){var K=H.expected_type[0];
N.expectedType=K.id;
N.expectedTypeLabel=K.name;
N.cvt=K["/freebase/type_hints/mediator"]==true;
if(!C.hasTypeRecord(K.id)&&N.cvt){M[K.id]=true;
}}}};
var A=function(I,L,H){var K=[];
for(var J in I){K.push(J);
}if(K.length>0){E(K,L,H);
}else{L();
}};
C.tryGetTypeLabel=function(L,I){if("getTypeID" in L){var N=5;
var K=null;
var J=function(){if(K in C._typeRecords){var O=C._typeRecords[K].name;
I(O);
}else{N--;
if(N>0){window.setTimeout(J,1000);
}else{}}};
var M=5;
var H=function(){K=L.getTypeID();
if(K!=null){J();
}else{M--;
if(M>0){window.setTimeout(H,1000);
}else{}}};
H();
}};
C.tryGetPropertyLabel=function(I,H){if(I in C._propertyRecords){H(C._propertyRecords[I].name);
}else{G.freebase.mql.read([{"id":I,"name":null}],function(J){H(J.result[0].name);
},G.freebase.mql.error);
}};
})();


/* type-stack.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.TypeStack=function(C,D,E){this._queryNode=C;
this._includeNativeTypes=(D);
this._useCVTsAsIs=(E);
this._typeRecords=null;
this._currentTypeRecord=0;
this._processedProperties={};
};
A.prototype.dispose=function(){this._queryNode=null;
this._typeRecords=null;
};
A.prototype.getTypeCount=function(){return this._typeRecords!=null?this._typeRecords.length:0;
};
A.prototype.getAllDimensions=function(){var D=[];
if(this._typeRecords!=null){for(var C=0;
C<this._typeRecords.length;
C++){D=D.concat(this._typeRecords[C].dimensions);
}}return D;
};
A.prototype.runWhenInitialized=function(E){if(this._typeRecords!=null){E();
return false;
}else{var C=this;
var D=function(F){C._buildTypeRecords(F||[]);
C._builtTypeRecords=true;
E();
};
B.freebase.schemas.projectTopicsToTypesPreloadSchemas(this._queryNode,D);
return true;
}};
A.computeDimensions=function(D,L,F,O,K,G,N,J,H){var M=B.freebase.schemas.getPropertyRecord(O);
if(typeof M!="object"){return ;
}if(M.expectedType!=null&&(J||!B.freebase.schemas.isNativeType(M.expectedType))){var P=K.clone();
P.appendSegment(O,true);
if(!H&&M.expectedType.indexOf("/measurement_unit/")!=0&&M.cvt){var E=M.expectedType;
var C=B.freebase.schemas.getTypeRecord(E);
if(C==null){return ;
}A._computeNestedDimensions(D,L,E,M.masterProperty,P,G+C.name+"/",N,J);
}else{var I=new B.freebase.Dimension(P);
I.typeID=L;
I.label=M.name;
I.fullLabel=G+M.name;
I.expectedType=M.expectedType;
I.expectedTypeLabel=M.expectedTypeLabel;
I.count=0;
D.push(I);
}}};
A._computeNestedDimensions=function(C,J,H,N,I,D,M,G){var L=B.freebase.schemas.getTypeRecord(H).properties;
for(var F=0;
F<L.length;
F++){var O=L[F];
var K=B.freebase.schemas.getPropertyRecord(O);
var E=K!=null&&K.unique;
if(O in M||(O==N&&E)){continue;
}M[O]=true;
A.computeDimensions(C,J,H,O,I,D,M,G,true);
}};
A.buildTypeRecord=function(G,C,J,F,D){var E=B.freebase.schemas.getTypeRecord(G);
if(E){var I=E.properties;
for(var H=0;
H<I.length;
H++){var K=I[H];
if(!(K in J)){J[K]=true;
A.computeDimensions(C,G,G,K,new B.freebase.PropertyPath(),"",J,F,D);
}}}};
A.prototype._buildTypeRecords=function(E){this._typeRecords=[];
for(var D=0;
D<E.length;
D++){var F=E[D];
if(B.freebase.schemas.hasTypeRecord(F.id)&&F.id!="/common/topic"){var C={typeID:F.id,count:F.count,dimensions:[],processedDimensions:0};
A.buildTypeRecord(F.id,C.dimensions,this._processedProperties,this._includeNativeTypes,this._useCVTsAsIs);
if(C.dimensions.length>0){this._typeRecords.push(C);
}}}this._typeRecords.sort(function(H,G){var I=G.count-H.count;
if(I==0){I=H.typeID.localeCompare(G.typeID);
}return I;
});
};
A.prototype.runOnDimensionsOfNextType=function(D){var C=this;
if(this._typeRecords!=null){return this._internalRunOnDimensionsOfNextType(D);
}else{this.runWhenInitialized(function(){C._internalRunOnDimensionsOfNextType(D);
});
return true;
}};
A.prototype._internalRunOnDimensionsOfNextType=function(H){if(this._currentTypeRecord<this._typeRecords.length){var D=this._typeRecords[this._currentTypeRecord];
var C=this;
var G=this._queryNode;
var I=function(){D.processedDimensions++;
if(D.processedDimensions>=D.dimensions.length){C._currentTypeRecord++;
H(D,D.dimensions);
}};
var F=function(K){var J=B.system.clone(G);
K.getPath().forEachSegment(function(L){var M={};
M[B.freebase.PropertyPath.segmentToBackwardMqlKey(L)]=[J];
J=M;
});
J["return"]=D.count>1000?"estimate-count":"count";
B.freebase.mql.read([J],function(L){K.count=L.result[0];
I();
},I);
};
for(var E=0;
E<D.dimensions.length;
E++){F(D.dimensions[E]);
}return true;
}else{return false;
}};
})();


/* parser.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.PathExpression={};
A.parse=function(E,G,C){G=G||0;
C=C||{};
var D=new A.Scanner(E,G);
try{var F=A._internalParse(D,null);
C.expression=F;
return F;
}finally{C.index=D.token()!=null?D.token().start:D.index();
}};
A.parseForContext=function(G,C,I,E){I=I||0;
E=E||{};
var F=new A.Scanner(G,I);
try{var D={index:C};
var H=A._internalParse(F,D);
E.expression=H;
return D;
}finally{E.index=F.token()!=null?F.token().start:F.index();
}};
A._internalParse=function(K,F){var C=A.Scanner;
var J=K.token();
var L=function(){K.next();
J=K.token();
};
var N=function(){return J!=null?J.start:K.index();
};
var O=function(){if(J==null){if(F!=null){return null;
}else{throw new Error("Missing factor at end of expression");
}}var P=null;
if(J.type==C.NUMBER||J.type==C.STRING||J.type==C.FREEBASE_ID){switch(J.type){case C.NUMBER:P=new A._Constant(J.value,"number");
break;
case C.STRING:P=new A._Constant(J.value,"string");
break;
case C.FREEBASE_ID:P=new A._Constant(J.value,"freebase-id");
break;
}if(F!=null){if(F.index>J.start&&F.index<=J.end){F.token=J;
F.type="generic";
}}L();
}else{switch(J.type){case C.IDENTIFIER:var R=J.value;
if(F!=null){if(F.index>J.start&&F.index<=J.end){F.token=J;
F.type="generic";
}}L();
if(R in A.Controls){if(J!=null&&J.type==C.DELIMITER&&J.value=="("){var U=J.end;
L();
if(F!=null){if(F.index>=U&&(J==null||F.index<=J.start)){F.token=J;
F.type="control";
F.identifier=R;
F.elementIndex=0;
}}var Q=(J!=null&&J.type==C.DELIMITER&&J.value==")")?[]:G("control",R,0);
P=new A._ControlCall(R,Q);
if(J!=null&&J.type==C.DELIMITER&&J.value==")"){var T=J.end;
L();
if(F!=null){if(F.index>=T&&(J==null||F.index<=J.start)){F.token=J;
F.type="generic";
}}}else{if(F==null){throw new Error("Missing ) to end "+R+" at position "+N());
}}}else{throw new Error("Missing ( to start "+R+" at position "+N());
}}else{if(J!=null&&J.type==C.DELIMITER&&J.value=="("){var U=J.end;
L();
if(F!=null){if(F.index>=U&&(J==null||F.index<=J.start)){F.token=J;
F.type="function";
F.identifier=R;
F.elementIndex=0;
}}var Q=(J!=null&&J.type==C.DELIMITER&&J.value==")")?[]:G("function",R,0);
P=new A._FunctionCall(R,Q);
if(J!=null&&J.type==C.DELIMITER&&J.value==")"){var T=J.end;
L();
if(F!=null){if(F.index>=T&&(J==null||F.index<=J.start)){F.token=J;
F.type="generic";
}}}else{if(F==null){throw new Error("Missing ) after function call "+R+" at position "+N());
}}}else{if(R=="true"){P=new A._Constant(true,"boolean");
}else{if(R=="false"){P=new A._Constant(false,"boolean");
}else{P=new A._Constant(R,"identifier");
}}}}break;
case C.DELIMITER:if(J.value=="("){var U=J.end;
L();
if(F!=null){if(F.index>=U&&(J==null||F.index<=J.start)){F.token=J;
F.type="generic";
}}P=D();
if(J!=null&&J.type==C.DELIMITER&&J.value==")"){L();
break;
}else{if(F==null){throw new Error("Missing ) at position "+N());
}}}else{if(J.value=="["){var U=J.end;
L();
if(F!=null){if(F.index>=U&&(J==null||F.index<=J.start)){F.token=J;
F.type="generic";
}}var S=(J!=null&&J.type==C.DELIMITER&&J.value=="]")?[]:G("generic",null);
P=new A._ConstantArray(S);
if(J!=null&&J.type==C.DELIMITER&&J.value=="]"){L();
break;
}else{if(F==null){throw new Error("Missing ] at end of array at position "+N());
}}}}default:if(F==null){throw new Error("Unexpected text "+J.value+" at position "+N());
}}}return P;
};
var M=function(){var R=O();
while(J!=null&&J.type==C.OPERATOR&&J.value=="."){var T=J.end;
L();
if(J==null||(J.type!=C.IDENTIFIER&&J.type!=C.FREEBASE_ID)){if(F!=null){if(F.index>=T&&(J==null||F.index<=J.start)){F.type="chain";
}break;
}else{throw new Error("Missing function name or Freebase ID at position "+N());
}}if(F!=null){if(F.index>=T&&(J==null||F.index<=J.end)){F.token=J;
F.type="chain";
}}if(J.type==C.IDENTIFIER){var Q=J.value;
L();
if(J==null||J.type!=C.DELIMITER||J.value!="("){if(F==null){throw new Error("Missing ( at position "+N());
}else{break;
}}var S=J.end;
L();
if(F!=null){if(F.index>=S&&(J==null||F.index<=J.start)){F.token=J;
F.type="function";
F.identifier=Q;
F.elementIndex=1;
}}var P=(J!=null&&J.type==C.DELIMITER&&J.value==")")?[]:G("function",Q,1);
P.unshift(R);
R=new A._FunctionCall(Q,P);
if(J==null||J.type!=C.DELIMITER||J.value!=")"){if(F==null){throw new Error("Missing ) at position "+N());
}else{break;
}}L();
}else{R=new A._FunctionCall("pivot",[R,O()]);
}}return R;
};
var E=function(){var Q=M();
while(J!=null&&J.type==C.OPERATOR&&(J.value=="*"||J.value=="/")){var R=J.end;
var P=J.value;
L();
if(F!=null){if(F.index>=R&&(J==null||F.index<=J.start)){F.token=J;
F.type="operator";
F.operator=P;
}}Q=new A._Operator(P,[Q,M()]);
}return Q;
};
var I=function(){var Q=E();
while(J!=null&&J.type==C.OPERATOR&&(J.value=="+"||J.value=="-")){var R=J.end;
var P=J.value;
L();
if(F!=null){if(F.index>=R&&(J==null||F.index<=J.start)){F.token=J;
F.type="operator";
F.operator=P;
}}Q=new A._Operator(P,[Q,E()]);
}return Q;
};
var D=function(){var R=I();
while(J!=null&&J.type==C.OPERATOR&&(J.value=="="||J.value=="<>"||J.value=="<"||J.value=="<="||J.value==">"||J.value==">=")){var Q=J.end;
var P=J.value;
L();
if(F!=null){if(F.index>=Q&&(J==null||F.index<=J.start)){F.token=J;
F.type="operator";
F.operator=P;
}}R=new A._Operator(P,[R,I()]);
}return R;
};
var H=function(P,Q,R){var T=N();
var U=J;
var S=D();
if(F!=null){if(S!=null&&S.getValueType()=="identifier"&&S instanceof A._Constant&&F.index>=T&&(J==null||F.index<=J.start)){F.token=U;
F.type=P;
if(Q!=null){F.identifier=Q;
F.elementIndex=R;
}}}return S;
};
var G=function(P,R,Q){var T=0;
var S=[H(P,R,Q)];
while(J!=null&&J.type==C.DELIMITER&&J.value==","){var U=J.end;
T++;
L();
if(F!=null){if(F.index>=U&&(J==null||F.index<=J.start)){F.token=J;
F.type=P;
if(R!=null){F.identifier=R;
F.elementIndex=T+Q;
}}}S.push(H(P,R,Q+T));
}return S;
};
return new A._Impl(D());
};
A.Scanner=function(D,C){this._text=D+" ";
this._maxIndex=D.length;
this._index=C;
this.next();
};
A.Scanner.DELIMITER=0;
A.Scanner.NUMBER=1;
A.Scanner.STRING=2;
A.Scanner.OPERATOR=3;
A.Scanner.IDENTIFIER=4;
A.Scanner.FREEBASE_ID=5;
A.Scanner.prototype.token=function(){return this._token;
};
A.Scanner.prototype.index=function(){return this._index;
};
A.Scanner._lowercaseLetters="abcdefghijklmnopqrstuvwxyz";
A.Scanner.prototype.next=function(){this._token=null;
while(this._index<this._maxIndex&&" \t\r\n".indexOf(this._text.charAt(this._index))>=0){this._index++;
}if(this._index<this._maxIndex){var E=this._text.charAt(this._index);
var D=this._text.charAt(this._index+1);
if("<>".indexOf(E)>=0){if((D=="=")||("<>".indexOf(D)>=0&&E!=D)){this._token={type:A.Scanner.OPERATOR,value:E+D,start:this._index,end:this._index+2};
this._index+=2;
}else{this._token={type:A.Scanner.OPERATOR,value:E,start:this._index,end:this._index+1};
this._index++;
}}else{if(E=="/"&&A.Scanner._lowercaseLetters.indexOf(D)>=0){var C=this._index;
while(C<this._maxIndex){var F=this._text.charAt(C).toLowerCase();
if(A.Scanner._lowercaseLetters.indexOf(F)>=0||F=="_"||F=="/"){C++;
}else{break;
}}this._token={type:A.Scanner.FREEBASE_ID,value:this._text.substring(this._index,C),start:this._index,end:C};
this._index=C;
}else{if("+-*/=.".indexOf(E)>=0){this._token={type:A.Scanner.OPERATOR,value:E,start:this._index,end:this._index+1};
this._index++;
}else{if("()[],".indexOf(E)>=0){this._token={type:A.Scanner.DELIMITER,value:E,start:this._index,end:this._index+1};
this._index++;
}else{if("\"'".indexOf(E)>=0){var C=this._index+1;
while(C<this._maxIndex){if(this._text.charAt(C)==E&&this._text.charAt(C-1)!="\\"){break;
}C++;
}if(C<this._maxIndex){this._token={type:A.Scanner.STRING,value:this._text.substring(this._index+1,C).replace(/\\'/g,"'").replace(/\\"/g,'"'),start:this._index,end:C+1};
this._index=C+1;
}else{throw new Error("Unterminated string starting at "+this._index);
}}else{if(this._isDigit(E)){var C=this._index;
while(C<this._maxIndex&&this._isDigit(this._text.charAt(C))){C++;
}if(C<this._maxIndex&&this._text.charAt(C)=="."){C++;
while(C<this._maxIndex&&this._isDigit(this._text.charAt(C))){C++;
}}this._token={type:A.Scanner.NUMBER,value:parseFloat(this._text.substring(this._index,C)),start:this._index,end:C};
this._index=C;
}else{var C=this._index;
while(C<this._maxIndex){var F=this._text.charAt(C);
if("()[],.!@\t".indexOf(F)<0){C++;
}else{break;
}}this._token={type:A.Scanner.IDENTIFIER,value:jQuery.trim(this._text.substring(this._index,C)),start:this._index,end:C};
this._index=C;
}}}}}}}};
A.Scanner.prototype._isDigit=function(C){return"0123456789".indexOf(C)>=0;
};
})();


/* controls.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.PathExpression;
A.Controls={};
})();


/* evaluator.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.PathExpression;
A._Impl=function(C){this._rootNode=C;
};
A._Impl.prototype.evaluate=function(D,F,E){this._rootNode.prepare();
var C=this;
A.SchemaManager.processQueues(function(){C._rootNode.evaluate(D,function(G){if("query" in G){A.Util.evaluateIntermediateToTerminal(G,F,E);
}else{F(G);
}},E);
});
};
A._Impl.prototype.evaluateWithExtenders=function(F,H,I,C,E){try{this._rootNode.prepare();
for(var D in H){var J=H[D];
J._rootNode.prepare();
}for(var D in I){var J=I[D];
J._rootNode.prepare();
}var K=this;
A.SchemaManager.processQueues(function(){K._rootNode.evaluate(F,function(P){var O={};
var Q={};
var M=[];
for(var S in H){var R=H[S];
var L=R.extend(F,P,false);
O[S]=L;
M.push(L);
}for(var S in I){var R=I[S];
var L=R.extend(F,P,true);
Q[S]=L;
M.push(L);
}var N=function(T){A.Util.postProcessAccessors(M,T,function(U){C(U,O,Q);
},E);
};
if("query" in P){A.Util.evaluateIntermediateToTerminal(P,N,E);
}else{N(P,O,Q);
}},E);
});
}catch(G){log(G);
}};
A._Impl.prototype.extend=function(E,D,C){return this._rootNode.extend(E,D,C);
};
A._Constant=function(D,C){this._value=D;
this._valueType=C;
};
A._Constant.prototype.getValueType=function(){return this._valueType;
};
A._Constant.prototype.getValue=function(){return this._value;
};
A._Constant.prototype.prepare=function(){};
A._Constant.prototype.evaluate=function(C,E,D){E({valueType:this._valueType,values:[this._value]});
};
A._Constant.prototype.extend=function(G,F,E){if(this._valueType=="identifier"){if(this._value=="thing"){var H={access:function(I){return[I];
},needsPostProcessing:false};
if("query" in F){H["query"]=F.query;
}else{H["result"]=F;
}return H;
}else{var D=G[this._value];
return{result:D,access:function(I){return[D];
},needsPostProcessing:false};
}}else{var C=this;
return{result:{valueType:this._valueType,values:[this._value]},access:function(I){return[{value:C._value}];
},needsPostProcessing:false};
}};
A._ConstantArray=function(C){this._elements=C;
};
A._ConstantArray.prototype.getElements=function(){return[].concat(this._elements);
};
A._ConstantArray.prototype.prepare=function(){for(var C=0;
C<this._elements.length;
C++){this._elements[C].prepare();
}};
A._ConstantArray.prototype.evaluate=function(C,E,D){A.Util.evaluateArguments(this._elements,C,function(H){var J=null;
var F=[];
for(var G=0;
G<H.length;
G++){var I=H[G];
if("query" in I){D("array cannot contain query arguments");
return ;
}if(I.values.length>0){if(J==null){J=I.valueType;
}else{if(J!=I.valueType){D("array cannot contain elements of different types");
return ;
}}F=F.concat(I.values);
}}E({valueType:J,values:F});
},D);
};
A._ConstantArray.prototype.extend=function(F,E,D){var G=this._elements;
var C=[];
var H=A.Util.extendMany(F,E,D,G,C);
return{needsPostProcessing:H,postProcess:function(I,K,J){A.Util.postProcessAccessors(C,I,K,J);
},access:function(I){var J=[];
var M=null;
for(var K=0;
K<C.length;
K++){var L=C[K].access(I);
if(L!=null){if(M==null){M=L.valueType;
}else{if(M!=L.valueType){throw new Error("Elements in constant array have different types");
}}J=J.concat(L.values);
}}return{valueType:M,values:J};
}};
};
A._ControlCall=function(D,C){this._identifier=D;
this._args=C;
};
A._ControlCall.prototype.prepare=function(){throw new Error("Not implemented");
};
A._ControlCall.prototype.evaluate=function(C,E,D){throw new Error("Not implemented");
};
A._ControlCall.prototype.extend=function(E,D,C){throw new Error("Not implemented");
};
A._FunctionCall=function(D,C){this._identifier=D;
this._args=C;
};
A._FunctionCall.prototype.prepare=function(){for(var C=0;
C<this._args.length;
C++){this._args[C].prepare();
}var D=A.Functions[this._identifier];
if("prepare" in D){D.prepare(this._args);
}};
A._FunctionCall.prototype.evaluate=function(C,F,D){var E=A.Functions[this._identifier];
A.Util.evaluateArguments(this._args,C,function(G){E.evaluate(G,C,F,D);
},D);
};
A._FunctionCall.prototype.extend=function(E,D,C){var F=A.Functions[this._identifier];
if("extend" in F){return F.extend(E,D,C,this._args);
}else{throw new Error("Function does not implement extend");
}};
A._Operator=function(C,D){this._operator=C;
this._args=D;
};
A._Operator.prototype.prepare=function(){throw new Error("Not implemented");
};
A._Operator.prototype.evaluate=function(C,E,D){throw new Error("Not implemented");
};
A._Operator.prototype.extend=function(E,D,C){throw new Error("Not implemented");
};
A.SchemaManager={_properties:{},_queuedProperties:{}};
A.SchemaManager.queueProperty=function(C){if(!(C in A.SchemaManager._properties)&&C!="/type/object"){A.SchemaManager._queuedProperties[C]=true;
}};
A.SchemaManager.getPropertyRecord=function(C){return A.SchemaManager._properties[C];
};
A.SchemaManager.processQueues=function(F){var E=[];
for(var D in A.SchemaManager._queuedProperties){E.push(D);
}A.SchemaManager._queuedProperties={};
if(E.length>0){var C=[{"id|=":E,"id":null,"type":"/type/property","expected_type":[{"id":null,"optional":true}]}];
B.freebase.mql.read(C,function(G){A.SchemaManager._gotPropertySchemas(G,F);
},function(G){B.system.error(G);
F();
});
}else{F();
}};
A.SchemaManager._gotPropertySchemas=function(E,G){var D=E.result;
for(var C=0;
C<D.length;
C++){var F=D[C];
A.SchemaManager._properties[F.id]=F;
}G();
};
A.Util={evaluateArguments:function(E,H,J,I){var C=0;
var F=[];
var D=function(K){F.push(K);
G();
};
var G=function(){if(C<E.length){var K=E[C++];
K.evaluate(H,D,I);
}else{J(F);
}};
G();
},evaluateArgumentsToTerminals:function(F,H,J,I){var C=0;
var E=[];
var D=function(K){F.push(K);
G();
};
var G=function(){if(C<F.length){var K=F[C++];
if("query" in K){A.Util.evaluateIntermediateToTerminal(K,function(L){E.push(L);
G();
},I);
}else{E.push(K);
G();
}}else{J(E);
}};
G();
},evaluateIntermediateToTerminal:function(C,E,D){C.prepareToQuery();
B.freebase.mql.read(C.query,function(F){E(C.parseResult(F.result));
},D);
},queryMany:function(E,I,H){var C=0;
var F=[];
var D=function(J){argIntermediates.push(J);
G();
};
var G=function(){if(C<E.length){var J=E[C++];
B.freebase.mql.read(J,function(K){F.push(K.result);
G();
},function(L,K){H(L,K);
});
}else{I(F);
}};
G();
},postProcessAccessors:function(E,F,H,G){var C=0;
var D=function(){while(C<E.length){var I=E[C++];
if(I.needsPostProcessing){I.postProcess(F,D,G);
return ;
}}H(F);
};
D();
},extendMany:function(J,E,K,C,I){var D=false;
for(var G=0;
G<C.length;
G++){var H=C[G];
var F=H.extend(J,E,K);
if(F.needsPostProcessing){D=true;
}I.push(F);
}return D;
}};
})();


/* functions.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.PathExpression;
A.Functions={};
A.Types={Set:0,TopicID:1,TypeID:2,PropertyID:3,String:4,Number:5,Boolean:6,ConstantArray:7};
A.Functions["instances"]={argumentTypes:[{type:A.Types.TypeID}],returnType:{type:A.Types.Set},evaluate:function(C,E,H,F){var G=[{}];
var D={query:G,valueType:"topic",prepareToQuery:function(){G[0]["id"]=null;
G[0]["name"]=null;
},parseResult:function(I){return{values:I,valueType:"topic"};
}};
if(C.length==1&&"query" in C[0]){G[0]["type"]=C[0].query;
H(D);
}else{A.Util.evaluateArgumentsToTerminals(C,E,function(L){var M=[];
for(var K=0;
K<L.length;
K++){var N=L[K];
if(N.valueType=="topic"){var I=N.values;
for(var J=0;
J<I.length;
J++){M.push(I[J].id);
}}else{if(N.valueType=="freebase-id"){M=M.concat(N.values);
}}}G[0]["type|="]=M;
H(D);
},F);
}}};
A.Functions["topic"]={argumentTypes:[{type:A.Types.TopicID}],returnType:{type:A.Types.Set},evaluate:function(C,E,H,F){var G=[{}];
var D={query:G,valueType:"topic",prepareToQuery:function(){G[0]["id"]=null;
G[0]["name"]=null;
},parseResult:function(I){return{values:I,valueType:"topic"};
}};
A.Util.evaluateArgumentsToTerminals(C,E,function(M){var I=[];
for(var L=0;
L<M.length;
L++){var N=M[L];
if(N.valueType=="topic"){var J=N.values;
for(var K=0;
K<J.length;
K++){I.push(J[K].id);
}}else{if(N.valueType=="freebase-id"){I=I.concat(N.values);
}}}G[0]["id|="]=I;
H(D);
},F);
}};
A.Functions["count"]={argumentTypes:[{type:A.Types.Set}],returnType:{type:A.Types.Number},evaluate:function(D,I,C,H){var K=0;
var G=[];
for(var F=0;
F<D.length;
F++){var E=D[F];
if("query" in E){E.prepareToQuery();
var J=E.query;
J[0]["return"]="count";
G.push(J);
}else{K+=E.values.length;
}}if(G.length==0){C({valueType:"number",values:[K]});
}else{A.Util.queryMany(G,function(N){for(var M=0;
M<N.length;
M++){var L=N[M];
if(L.length>0){K+=L[0];
}}C({valueType:"number",values:[K]});
},H);
}}};
A.Functions["group"]={argumentTypes:[{type:A.Types.Set},{type:A.Types.PropertyID}],returnType:{type:A.Types.Set},evaluate:function(F,I,D,H){if(F.length<2){H("group function expects 2 arguments");
}var E=F[0];
var P=F[1];
if(P.valueType!="freebase-id"){H("group function expects its second argument to be a Freebase ID");
return ;
}if("query" in E){var C=null;
var M=null;
var L=E.query[0];
var J=P.values;
for(var G=0;
G<J.length;
G++){var N=J[G];
var O="!"+N;
var K={};
K[O]=[L];
M=O;
C=L;
L=K;
}C["return"]="count";
D({query:[L],valueType:"complex",prepareToQuery:function(){L["id"]=null;
L["name"]=null;
},parseResult:function(T){var R=[];
for(var S=0;
S<T.length;
S++){var Q=T[S];
Q["count"]=Q[M][0];
R.push(Q);
}return{values:R,valueType:"complex"};
}});
}else{H("group function expects its first argument to be a query");
}}};
A.Functions["head"]={argumentTypes:[{type:A.Types.Set},{type:A.Types.PropertyID},{type:A.Types.Boolean},{type:A.Types.Number}],returnType:{type:A.Types.Set},evaluate:function(N,S,L,I){if(N.length<2){I("head function expects at least 2 arguments");
}var Q=N[0];
var P=N[1];
var K=3;
var C=true;
var J;
if(Q.valueType!="topic"&&Q.valueType!="complex"){I("head function expects its first argument to be return topics or complex objects");
return ;
}if((P.valueType!="string"&&P.valueType!="freebase-id")||P.values.length!=1){I("head function expects its second argument to be a string or a Freebase ID");
return ;
}else{J=P.values[0];
}if(N.length>2){var F=N[2];
if(F.valueType!="boolean"||F.values.length!=1){I("head function expects its third argument to be a boolean");
return ;
}C=F.values[0];
}if(N.length>3){var M=N[3];
if(M.valueType!="number"||M.values.length!=1){I("head function expects its fourth argument to be a number");
return ;
}K=M.values[0];
}if(J!="count"&&"query" in Q){var J=P.values[0];
var G=Q.query;
var R=G[0];
R["sort"]=(C?"":"-")+J;
R["limit"]=K;
if(!(J in R)){R[J]=null;
}L({query:G,valueType:Q.valueType,prepareToQuery:Q.prepareToQuery,parseResult:Q.parseResult});
}else{var D=function(V,U){var X=V[J];
var W=U[J];
return X.localeCompare(W);
};
var T=function(V,U){var X=V[J];
var W=U[J];
return X-W;
};
var E=(J=="count")?T:D;
var H=C?E:function(V,U){return E(U,V);
};
var O=function(U){U.values.sort(H);
L({valueType:U.valueType,values:U.values.slice(0,K)});
};
if("query" in Q){A.Util.evaluateArgumentsToTerminals([Q],S,function(U){O(U[0]);
},I);
}else{O(Q);
}}}};
A.Functions["tail"]={argumentTypes:[{type:A.Types.Set},{type:A.Types.PropertyID},{type:A.Types.Boolean},{type:A.Types.Number}],returnType:{type:A.Types.Set},evaluate:function(N,S,L,I){if(N.length<2){I("tail function expects at least 2 arguments");
}var Q=N[0];
var P=N[1];
var K=3;
var C=false;
var J;
if(Q.valueType!="topic"&&Q.valueType!="complex"){I("tail function expects its first argument to be return topics or complex objects");
return ;
}if((P.valueType!="string"&&P.valueType!="freebase-id")||P.values.length!=1){I("tail function expects its second argument to be a string or a Freebase ID");
return ;
}else{J=P.values[0];
}if(N.length>2){var F=N[2];
if(F.valueType!="boolean"||F.values.length!=1){I("tail function expects its third argument to be a boolean");
return ;
}C=!F.values[0];
}if(N.length>3){var M=N[3];
if(M.valueType!="number"||M.values.length!=1){I("tail function expects its fourth argument to be a number");
return ;
}K=M.values[0];
}if(J!="count"&&"query" in Q){var J=P.values[0];
var G=Q.query;
var R=G[0];
R["sort"]=(C?"":"-")+J;
R["limit"]=K;
if(!(J in R)){R[J]=null;
}L({query:G,valueType:Q.valueType,prepareToQuery:Q.prepareToQuery,parseResult:Q.parseResult});
}else{var D=function(V,U){var X=V[J];
var W=U[J];
return X.localeCompare(W);
};
var T=function(V,U){var X=V[J];
var W=U[J];
return X-W;
};
var E=(J=="count")?T:D;
var H=C?E:function(V,U){return E(U,V);
};
var O=function(U){U.values.sort(H);
L({valueType:U.valueType,values:U.values.slice(0,K)});
};
if("query" in Q){A.Util.evaluateArgumentsToTerminals([Q],S,function(U){O(U[0]);
},I);
}else{O(Q);
}}}};
A.Functions["sort"]={argumentTypes:[{type:A.Types.Set},{type:A.Types.PropertyID},{type:A.Types.Boolean}],returnType:{type:A.Types.Set},evaluate:function(H,L,E,K){if(H.length<2){K("sort function expects at least 2 arguments");
}var F=H[0];
var R=H[1];
var I=true;
var Q;
if(F.valueType!="topic"&&F.valueType!="complex"){K("sort function expects its first argument to be return topics or complex objects");
return ;
}if((R.valueType!="freebase-id"&&R.valueType!="string")||R.values.length!=1){K("sort function expects its second argument to be a string or a Freebase ID");
return ;
}else{Q=R.values[0];
}if(H.length>2){var G=H[2];
if(G.valueType!="boolean"||G.values.length!=1){K("sort function expects its fourth argument to be a boolean");
return ;
}I=G.values[0];
}if(Q!="count"&&"query" in F){var Q=R.values[0];
var M=F.query;
var N=M[0];
N["sort"]=(I?"":"-")+Q;
if(!(Q in N)){N[Q]=null;
}E({query:M,valueType:F.valueType,prepareToQuery:F.prepareToQuery,parseResult:F.parseResult});
}else{var D=function(T,S){var V=T[Q];
var U=S[Q];
return V.localeCompare(U);
};
var P=function(T,S){var V=T[Q];
var U=S[Q];
return V-U;
};
var O=(Q=="count")?P:D;
var C=I?O:function(T,S){return O(S,T);
};
var J=function(S){S.values.sort(C);
E(S);
};
if("query" in F){A.Util.evaluateArgumentsToTerminals([F],L,function(S){J(S[0]);
},K);
}else{J(F);
}}}};
A.Functions["pivot"]={argumentTypes:[{type:A.Types.Set},{type:A.Types.PropertyID}],returnType:{type:A.Types.Set},prepare:function(D){var C=D[1];
if(C instanceof A._Constant){A.SchemaManager.queueProperty(C.getValue());
}else{if(C instanceof A._ConstantArray){var G=C.getElements();
for(var F=0;
F<G.length;
F++){var E=G[F];
if(E instanceof A._Constant){A.SchemaManager.queueProperty(E.getValue());
}}}}},evaluate:function(E,I,C,H){if(E.length<2){H("pivot function expects 2 arguments");
}var D=E[0];
var M=E[1];
if(M.valueType!="freebase-id"||M.values.length<1){H("pivot function expects its second argument to be a Freebase ID");
return ;
}if("query" in D){var J=D.query[0];
var K;
for(var F=0;
F<M.values.length;
F++){K=M.values[F];
var L=(K.charAt(0)=="!")?K:("!"+K);
var G={};
G[L]=[J];
J=G;
}C({query:[J],valueType:"topic",prepareToQuery:function(){var N=A.SchemaManager.getPropertyRecord(K);
if(N!=null&&"expected_type" in N&&N.expected_type[0].id.indexOf("/type/")==0){J["value"]=null;
}else{J["id"]=null;
J["name"]=null;
}},parseResult:function(N){return{values:N,valueType:"topic"};
}});
}else{H("pivot function expects its first argument to be a query");
}},extend:function(J,E,L,K){var G=[];
var D=A.Util.extendMany(J,E,L,K,G);
if(D){throw new Error("pivot does not know how to extend when some of its arguments need post processing");
}if("query" in G[0]){var N=G[0].query;
if(N instanceof Array){N=N[0];
}}else{throw new Error("pivot does not know how to extend non-query sets");
}if("result" in G[1]){var C=G[1].result;
if(C.valueType=="freebase-id"){var H="p"+Math.floor(Math.random()*100);
var M=C.values[0];
var O=H+":"+M;
var F={};
var I=A.SchemaManager.getPropertyRecord(M);
if(I!=null&&"expected_type" in I&&I.expected_type[0].id.indexOf("/type/")==0){F["value"]=null;
}else{F["id"]=null;
F["name"]=null;
}if(L){F["optional"]=true;
}N[O]=[F];
}else{throw new Error("pivot does not know how to extend by something other than a property specified as a Freebase ID");
}}else{throw new Error("pivot does not know how to extend by a non-constant property");
}return{needsPostProcessing:D,query:N[O],postProcess:function(P,R,Q){throw new Error("pivot does not know how to post process yet");
},access:function(Q){var R=G[0].access(Q);
var V=[];
for(var T=0;
T<R.length;
T++){var U=R[T];
if(U!=null&&O in U){var P=U[O];
if(P!=null){for(var S=0;
S<P.length;
S++){V.push(P[S]);
}}}}return V;
}};
}};
A.Functions["filter"]={argumentTypes:[{type:A.Types.Set},{type:A.Types.PropertyID},{type:A.Types.TopicID}],returnType:{type:A.Types.Set},evaluate:function(E,I,C,H){if(E.length<3){H("filter function expects 3 arguments");
}var D=E[0];
var N=E[1];
if(N.valueType!="freebase-id"||N.values.length<1){H("filter function expects its second argument to be a Freebase ID");
return ;
}var J=E[2];
if(J.valueType!="freebase-id"||J.values.length<1){H("filter function expects its third argument to be a Freebase ID");
return ;
}if("query" in D){var K=D.query;
var L=K[0];
for(var F=0;
F<N.values.length;
F++){var M=N.values[F];
var G={};
L[M]=[G];
L=G;
}L["id|="]=J.values;
C({query:K,valueType:D.valueType,prepareToQuery:D.prepareToQuery,parseResult:D.parseResult});
}else{H("filter function expects its first argument to be a query");
}}};
A.Functions["geolocation"]={argumentTypes:[{type:A.Types.Set}],returnType:{type:A.Types.Set},evaluate:function(C,D,F,E){throw new Error("geolocation is only intended for extending, not for evaluating");
},extend:function(H,D,J,I){var F=[];
var C=A.Util.extendMany(H,D,J,I,F);
if(C){throw new Error("geolocation does not know how to extend when some of its arguments need post processing");
}if("query" in F[0]){var K=F[0].query;
if(K instanceof Array){K=K[0];
}}else{throw new Error("geolocation does not know how to extend non-query sets");
}var G="p"+Math.floor(Math.random()*100);
var L=G+":/location/location/geolocation";
var E={"/location/geocode/latitude":null,"/location/geocode/longitude":null};
if(J){E["optional"]=true;
}K[L]=[E];
return{needsPostProcessing:C,query:K[L],postProcess:function(M,O,N){throw new Error("geolocation does not know how to post process yet");
},access:function(N){var P=F[0].access(N);
var T=[];
for(var R=0;
R<P.length;
R++){var S=P[R];
if(L in S){var M=S[L];
if(M!=null){for(var Q=0;
Q<M.length;
Q++){var O=M[Q];
T.push({lat:O["/location/geocode/latitude"],lng:O["/location/geocode/longitude"]});
}}}}return T;
}};
}};
A.Functions["datediff"]={argumentTypes:[{type:A.Types.String},{type:A.Types.String}],returnType:{type:A.Types.Number},evaluate:function(C,D,F,E){throw new Error("datediff is only intended for extending, not for evaluating");
},extend:function(G,F,E,D){var C=[];
var I=A.Util.extendMany(G,F,E,D,C);
var H={needsPostProcessing:I,postProcess:function(J,L,K){A.Util.postProcessAccessors(C,J,L,K);
},access:function(R){var O=C[0].access(R);
var P=C[1].access(R);
var L=C[2].access(R);
var N=[];
if(L.length==1&&O.length==1&&P.length==1){var J=SimileAjax.DateTime.parseIso8601DateTime(O[0].value);
var M=SimileAjax.DateTime.parseIso8601DateTime(P[0].value);
if(J!=null&&M!=null){var K=M.getTime()-J.getTime();
var Q;
switch(L[0].value){case"year":Q=Math.floor(Math.abs(K)/31536000000);
break;
}N.push({value:Q});
}}return N;
}};
return H;
}};
})();


/* terminal.js */
window.MetawebSuite.system.onFinishLoadingPackage("metaweb-suite-freebase");
